Test with Mocha


  • What I am doing.
  • Review of my work refactoring the project “Cuanto me puedo gastar”
  • Test with mocha
  • CommonJS
  • Future projects & heading.


We started talking about what I’ve been doing and if I would like to go after some concrete subject.

So we went to review my work with the project “Cuanto me puedo gastar”, we took the function I have refactored
and put it in a new file calculate_mortage.js

important when creating functions use adverbs

While doing it we installed the package JS-Beautify but we didn’t used much, so I have to investigate a little because I was using HTML-Prettify that was working for me like charm.

After it we created a new file for the test called test.js so we could run mocha the right way.

So we went with iTerm to the directory where the project is hosted and we called mocha mocha -w test.js
but nothing happened because I had a wrong $PATH set and it wasn’t looking into the proper directory so we had to call it directly $ ./node_modules/.bin/mocha -w test.js

But we got another error and it was this time because we weren’t using at the end of the file we had intention to test calculate_mortage.js the following code: module.exports = calculateMortage that comes from CommonJS another thing to learn with a conditional so it was only executed when the module wasn’t undefined (I still have to find out why)

So now we made it run and we got the two test running, that by the way, after extracting it to the file test.js we had to change only the equal parameter to eql: asserts loose equality that works with objects so at least I had some test ready.

AirCrewMentor specified that I need to set up many test because right now the code is not really being tested since I only tested the function in the way I know it works, we need to try to break the code in the different situations we can find once the people is using the code.

So after all that we used the last minutes of the session to focus on the heading we need to take, first I need to finish the CodeSchool course I’m on right now and after that follow with the book Head First JS.

We talked about a project for skydivers where they could share the results of their jumps and their parameters so once we have a community big enough we can start selling our software to Dropzones so they can manage the Dropzone integrated with the community already created.

So it is better to go and create a new project that have a target user group as big as possible, there are a lot more skydivers than Dropzones.

This is going to be a project really amazing where I can get up to date with the new HTML5 that I don’t know nothing about it, as well as CSS3

After completing a project like this one I will be ready to find a job as a software developer.

To learn HTML5 and CSS3 we’ll find a book from Head First.

Here we can find all the features that are available at the moment for HTML5 https://html5test.com/

http://caniuse.com/ indicate the compatibility of the feature I want to use.

REMARK – Next session with the laptop easier to share full screen


  • AirCrewMentor seemed happy with the way I am startig to think making small packages of code that can run individually.
  • I almost got the objectives stablished in the previous session:
  • the test in mocha was ready but not properly configured, now I know how to set it up.
  • I got my own dotfiles and I am playing with them customizing to my own taste, using GitHub syncing within computers. (really loving it, I never thought I could do such things)

Objectives Next Session

  • I have to prepare the content or areas where I want to focus the complete Session.

Research Done.

  • Fixed the $PATH problem:

Added export PATH="./node_modules/.bin/:$PATH";  to a new file .path inside my dotfiles folder to avoid override when updating from the original dotfiles source.

This week I’ve learned a lot about the dotfiles and got mine personalized so now I am feeling really comfy with the shell, still a lot to learn ahead but I am happy with the evolution. Now I prefer to use terminal rather than finder.
– Found explanation and understood what are the package.json files for

Thanks AirCrewMentor for your time and dedication. Loving every minute.

One thought on “Test with Mocha

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s