Mocha with Chai

Chai is an assertion library. It makes it easy to throw errors when things are not as we expect them to be. Chai has two styles: "TDD" and "BDD". We'll be using the "BDD" style.

We have already installed Chai when we ran npm install and it has also been configured in the karma config file. So, now we can go straight to using it.

  describe('Simple Test', () => {
    it('2*2 should equal 4', () => {
      let x = 2 * 2;
      let y = 4;
      // Assert that x is defined.
      // Assert that x equals to specific value.
      // Assert that x equals to y.
      // See for more assertion options.