I'm having an issue where mocha --watch is only loading changes to the actual *.test.js files in my test folder, but not the supporting files in my src. After searching a bit I'm lead to believe this is due to require caching my src. Is this expected behaviour? And how do I best work around it / the correct way to watch files.
Hmm, with the new change I'm still getting the same issue.
This is the command I'm using
./node_modules/.bin/mocha --watch-files test,src --watch --recursive
'test' and 'src' are directories in the package root.
changes made in 'test' are picked up, changes made in 'src' do trigger a test re-run but the changes are not present
test/main.jsfile that requires
src/index.js. If I modify
src/index.jsthese changes are reflected in the subsequent test run triggered by the watcher. Would you mind opening an issue on Github so we can investigate this further?
@raghanag ts-mocha is a wrapper over mocha so not sure if completely follow that part. if its a TS issue we have an example TS mocha here https://github.com/mochajs/mocha-examples/tree/master/typescript.
The other part of ur question, u can create a
load-libs.js file which requires all your libs and use
mocha —require load-libs.js to load them before tests.
Does this help? if not pls supply more details about problem.
setup(...)function part of the mocha test library, I am looking at some code 4yo, and It seems this is part of mocha?