What is the simplest way to tell Mocha to watch for source project files changes so that it can re-runs its tests?
Run with the watch flag
mocha -w ./tests
And, if your test folder is called just test/ then you don't need to point out the folder (Mocha looks for changes in such folder by default), so you can end up just with:
mocha -w
                        I definitely do not recommend mocha watch function for the following reasons:
To solve this, I did the following changes on my project:
npm install nodemon --save-dev;npm install mocha --save-dev;./test to point to your test folder: ./node_modules/nodemon/bin/nodemon.js --watch . --exec 'mocha ./test || true';scripts.test section in the file package.json to make you life easy;References:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With