faq labelnode node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha. (N/A - no global version installed)mocha --watch doesn't detect the tests. Output: 0 passing (10 ms). It did in the 5.2.0 version.
Update to 6.0.0, write a test or use the ones you already have and try to execute the watcher. mocha will work, mocha --watch wont.
Expected behavior: [What you expect to happen]
mocha --watch detect the tests, Actual behavior: [What actually happens]
mocha --watch doesn't detect any test.Reproduces how often: [What percentage of the time does it reproduce?]
100%
mocha --version and node node_modules/.bin/mocha --version: 6.0.0node --version: 11.9.0I can confirm that I am seeing similar issues. I just tried version 6 and the --watch is not working as it was in 5. I am working on a mac book pro. I pushed branch up to show the issue.
npm run test:watch-mocha
if you downgrade to mocha 5, watch will start working.
This is a typescript based project of my own but simpler pure JS projects have the same issue. I have updated the readme on this branch with instructions. I'm sure you may not need additional examples but here you are anyway.
Using Glen's repo, migrated all test related code into "test" directory.
$ DEBUG=mocha:watch mocha --require 'test/register.js' --watch 'src/**/*.ts' 'test/**/*.spec.ts' --extensions 'ts,js'
0 passing (1ms)
mocha:watch file /tmp/sample-node-typescript-module/src/foo.js +0ms
mocha:watch file /tmp/sample-node-typescript-module/test/cmd/index.spec.js +2ms
mocha:watch file /tmp/sample-node-typescript-module/test/register.js +0ms
Running this, I don't see any TypeScript files getting picked up (as though --watch-extensions was just ".js"). Adding JS files would increase output watched files.
Does it work for anyone on a vanilla JS project (i.e., no transpiling)?
many thanks @plroebuck I created a plain vanilla repo with the same result. My sincere thanks to the mocha team. I know how hard it is to push out code 馃
It doesn't work in my vanilla JS project neither, that's where I originally got the bug
@plroebuck only --watch-extensions and --extension are currently valid (not --extensions)
I'm having trouble reproducing any problems with @ghinks's repo. (thanks for the repo)
(the typescript repo, anyway)
OK, I can confirm a problem with the vanilla one
OK, I think I have a fix. unfortunately the watch stuff is tough to test.
see #3755
Sincere thanks
@plroebuck only
--watch-extensionsand--extensionare currently valid (not--extensions)
Why the naming mismatch?
And why didn't I get an error using an invalid cmdline option?
Most helpful comment
many thanks @plroebuck I created a plain vanilla repo with the same result. My sincere thanks to the mocha team. I know how hard it is to push out code 馃