chai expect error code example
Example 1: mocha should throw error
describe('createMap', () => {
it('should throw an error if no contents were sent as argument', () => {
expect(() => createMap()).to.throw('You have to send a list of things to map.');
});
});
Example 2: what does chai expect return
Object.prototype.b = 2;
expect({a: 1}).to.have.own.property('a');
expect({a: 1}).to.have.property('b');
expect({a: 1}).to.not.have.own.property('b');
expect({a: 1}).to.own.include({a: 1});
expect({a: 1}).to.include({b: 2}).but.not.own.include({b: 2});
Example 3: chai expect to be type array
expect([1, 2]).to.be.an('array');