Skip to content

mocha.js

Tutorial

Example from Docs


npm install --save-dev mocha

Save as test/sample.test.js


import assert from "assert"
// 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);
    });
  });
});

npx mocha