Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser. Getting started npm install --save-dev mocha Let's create a file named . test.js assert = ( ); describe( , { describe( , { it( , { assert.equal([ , , ].indexOf( ), ); }); }); }); const require 'assert' 'Array' ( ) function '#indexOf()' ( ) function 'should return -1 when the value is not present' ( ) function 1 2 3 4 -1 Baby steps! describe( , { describe( , { it( , { assert.notEqual( , [ , , ].indexOf( )); }); it( , { assert.equal( , [ , , ].indexOf( )); assert.equal( , [ , , ].indexOf( )); }); }); }); 'Array' ( ) function // suite '#indexOf()' ( ) function // suite 'should not return -1 when the value is present' ( ) function // test -1 1 2 3 3 'should return -1 when the value is not present' ( ) function // test -1 1 2 3 5 -1 1 2 3 0 Diving into async storm! describe( , { it( , { setTimeout( { assert.equal( , ); done(); }, ); }); }); // it uses `done`, just call it after you think your async will be finished 'SetTimeOut' ( ) function 'why everyone is scared of me' ( ) function done ( ) function 1 1 3000 // here timeout might give error, since the default timeout is 2 sec // though good news is you can alter it yourself using // flag --timeout 13000 or // programatically - this.timeout(13000) Delay the root suite! setTimeout( { describe( , { }); run(); }, ); .log( ); ( ) function 'master of all suites' ( ) function // write your cases here .. // again use flag --delay to use `run` function. 3000 console 'Timer begins for 3 seconds atleast' Hooks describe( , { before( , { }); after( , { }); beforeEach( , { }); afterEach( , { }); }); 'mocha hooks' ( ) function 'description here' ( ) function // runs before all test in this block 'description here' ( ) function // runs after all test in this block 'description here' ( ) function // runs before each test in this block 'description here' ( ) function // runs after each test in this block // your test cases here .. Juggling async Promises doSomethingAsync().then( { result.should.equal( ) done(); }, { done(err); }); doSomethingAsync().should.eventually.equal( ); describe( , { it( , { .resolve( + ).should.eventually.equal( ); }); }); // using chai-as-promised // bad ( ) function result 'foo' ( ) function err // good return 'foo' 'Promises' ( ) function 'deal with promises' ( ) function // (2+2).should.equal(4) // or return Promise 2 2 4 Dynamically generating test suites { [ ] + [ ]; } describe( , { tests = [{ : [ , ], : }, { : [ , ], : }, { : [ , ], : }]; tests.forEach( { it( + test.args.length + , { res = add.apply( , test.args); assert.equal(res, test.expected); }); }); }); // adds only two numbers ( ) function add return arguments 0 arguments 1 'add()' ( ) function var args 1 21 expected 22 args 11 3 expected 14 args 3 24 expected 27 ( ) function test 'correctly adds ' ' args' ( ) function var null Checkout more . here