node js testing code example
Example 1: 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);
});
});
});
Example 2: what is mocha js
Mocha is javascript test framework!
Example 3: mocha test cases in node js example
$ npm install --save mocha chai
Example 4: node.js testing 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);
});
});
});