With this function, this function has been added. The following is an example.
I got information from here:
You will need 2 files. One test, and one to run the test. You can mark runTest as an executable and set its output in the mocha options.
runTest.js
#!/usr/bin/env node var Mocha = require('mocha'), fs = require('fs'), path = require('path'); var mocha = new Mocha( { ui: 'tdd' }); mocha.addFile( path.join(__dirname, 'test.js') ); mocha.run(function(failures){ process.on('exit', function () { process.exit(failures); }); });
test.js
var assert = require('chai').assert suite('Array', function(){ setup(function(){}); suite('#indexOf()', function(){ test('should return -1 when not present', function(){ assert.equal(-1, [1,2,3].indexOf(4)); }); }); });
source share