Add the following development dependencies to your package.json
(from the command line):
Using npm:
$ npm install cross-env mocha chai sinon sinon-chai chai-as-promised chai-datetime --save-dev
Using Yarn:
$ yarn add cross-env mocha chai sinon sinon-chai chai-as-promised chai-datetime --dev
Copy the mocha.conf.js
file from this gist to your project's root directory.
Create the test/mocha.opts
file specifying the following mocha options:
--require chai/register-expect
--require mocha.conf.js
If you're using babel in your project, you can also add the following option:
--require babel-core/register
Finally, add the test
task to your package.json
's script
section:
{
...
"scripts": {
...
"test": "cross-env NODE_ENV=test mocha test/*.spec.js test/**/*.spec.js",
...
}
...
}
Done! You are ready to write your first test.