Hello World Mocha

Install Mocha globally:

npm install –g mocha

Then create the package.json file in your project directory:

npm init

And install should. Should is an assertion library that you need to match evaluations and computations:

npm install should --save-dev

Then make a simple file for your demo test. Let's call it demo.test.js. Put the following in the file:

var should = require("should");
var User = function(name){
    this.name = name;
};
describe("Checking if the user is created correctly", function(){
    it("should create the user with the correct name", function(){
        debugger
        var tom = new User("tom");
        tom.name.should.be.equal("tom");
    });
});

Now, you can run the test with mocha demo.test.js. You should get an output like the following:

	 Checking if the user is created correctly
	    ✓ should create the user with the correct name 
	  1 passing (7ms)