Mocha
Last updated
Was this helpful?
Last updated
Was this helpful?
Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser.
Lots of documentation is available on but here are a couple of notes that can be useful
"test": "mocha --watch"
will launch mocha which is globally installed and log for scripts in the test folder "./test/*.js"
"test": "mocha --recursive "./spec/*.js"
custom folder to look into can be configured
"test:utils": "mocha --config utils/__tests__/.mocharc.js"
--config can precise the location of the config file .mocharc.js
*"test:dev": "mocha -r mocha.env.js --watch "
-r
can include a module; useful for exemple to set the environment:
e.g process.env.NODE_ENV = 'development'
e.g
Edit the package.json to perform the coverage check of the test:
more details and ideas for configuration on
Install package npm i nyc --save-dev