Let's discuss chai. chai is an assertion library, used with mocha. We could also use the native assertion library , but chai adds a lot of flexibility.
chai makes it a lot easier to write test definitions. Let's install chai and modify the preceding test to make it look more simple and easy to understand:
$ npm install chai -g
We passed the -g option to install it globally, since we do not have a package.json configuration.
Let's use chai in our previous test. In add.spec.js, add the following lines of code:
var expect = require('chai').expect;
var addUtility = require("./../add.js");
describe('Add', function(){
describe('addUtility', function(){
it('should have a sum method', function(){
expect(addUtility).to.be.an('object');
expect(addUtility).to.have.property('sum&apos...