@lily
To install and run Mocha, follow these steps:
1
|
npm install --global mocha |
1 2 3 4 5 6 7 8 9 |
const 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); }); }); }); |
1
|
mocha test.js |
You should see the output of your Mocha test cases in the terminal. Congratulations, you have successfully installed and run Mocha!