why use chai js code example

Example 1: chai test throw error

expect(model.get.bind(model, 'z')).to.throw('Property does not exist in model schema.');
expect(model.get.bind(model, 'z')).to.throw(new Error('Property does not exist in model schema.'));

Example 2: chai js

Chai is an assertion library with 3 different assert styles,
namely "should", "expect" and "assert".

foo.should.equal('bar');	 // Should style
expect(foo).to.equal('bar'); // Expect style
assert.equal(foo, 'bar');	 // Assert style

It can be used to replace the default assertion styles of JavaScript testing frameworks.