Posts

Unit testing with Mocha & Chai for Node env. and Istanbul for code coverage

Unit testing with Mocha & Chai for Node env. Mocha Mocha is a JavaScript test framework for Node.js. For more details and documentation check its Github repo . To install mocha check below cmd: npm install mocha --save-dev Chai Chai is an assertion library, similar to Node’s build in assert. It makes testing much easier by giving you lots of assertions you can run against your code. For more details and documentation check its Github repo . To install Chai check below cmd: npm install chai --save-dev Chai provides both BDD (Behaviour Driven Development) as well as TDD (Test Driven Development) assertion style. The Expect / Should API covers the BDD assertion styles. The Assert API covers the TDD assertion style. Istanbul Istanbul provides code coverage report either on command line or as html report. For more details and documentation check its Github repo . To install mocha check below cmd: npm install nyc --save-dev Some other important links are: scotch.io si