mocha test throw the function 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: mocha js
Mocha is a JavaScript test framework!
var assert = require('assert');
describe('Array', function () {
describe('#indexOf()', function () {
it('should return -1 when the value is not present', function () {
assert.equal([1, 2, 3].indexOf(4), -1);
});
});
});