Tested with node 6.2.2 (https://nodejs.org/dist/v6.2.2/node-v6.2.2-x64.msi)
and current master build (v7.0.0-pre) built with MinGW 64 compiler
on Windows 8.1
npm install mocha -g installs mocha 2.5.3 with warnings
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
Going through walkthrough https://www.codementor.io/nodejs/tutorial/unit-testing-nodejs-tdd-mocha-sinon
Same results executing in a DOS prompt, or a MinGW64 console.
Running mocha tests --recursive --watch --colors where tests is a root level directory containing tests.
Correctly runs tests initially.
CartSummary
√ getSubtotal() should return 0 if no items are passed in
√ getSubtotal() should return the sum of the price * quantity of the items2 passing (6ms)
Then edit a test file to introduce non-breaking change.
Output appends
0 passing (0ms)
Any subsequent edits go ignored.
Changes to test files to trigger execution.
Subsequent edits to be noticed.
@WaffleSouffle what if you run mocha with less options, eg only --watch and try modifying tests/*.js?
This appears to be a Windows only bug.
As with #2330, I'd suggest using a purpose-built tool for watching. Mocha's built-in "watch" functionality is limited. Such functionality really deserves something which can support multiple platforms and edge cases.
@dasilvacontin Did you confirm this?
@boneskull No, I don't have a Windows setup.
Just tried to reproduce this on Windows and was unable to do so. I will double-check the tutorial and see if there might be something I missed.
...Yeah, I'm not seeing anything different that should affect this. My test doesn't have Chai and stuff, but that shouldn't matter... right?... I've got this on Windows 8.1, same directory structure, same command, Mocha installed globally...
I am having the same issue. I do not have this issue on Mac setup.
Debugging through it, it looks like the initial root suite is created with no tests, but with suites with tests, and then on "rerun", cloning the root suite does not copy the other suites, and no tests are added, so nothing runs on reRun. Not sure why this is only happening on Windows.
I also have such issue on windows.
npm version 3.10.3
node version 6.3.1
mocha version 3.0.2
For those having issues, please try passing a glob instead of the --recursive flag, and let me know if you have success:
# quotes are necessary
mocha "tests/**/*.js" --watch
UPDATE: Those may need to be backslashes? Try both. Enclosing the globspec in double-quotes means that the glob module will parse it; otherwise your shell would (whatever it is)
Any PR here should not grossly add to the level of complexity
@boneskull I've tried the workarounds you suggested both with slashes and backslashes with and without recursive flag and double/single quotes. None of that did help
@WaffleSouffle @jnields @dobryanskyy Could you please prepare a minimal setup that demonstrates this issue? 🤔
I think this would greatly help to pinpoint the root cause. 🤓
@dobryanskyy adding to what @gurdiga wrote, please keep it minimal unless you can provide the entire thing. also using "Babel" or "bundling" is a relevant detail; please include those
@boneskull yes, I'm using babel for jsx and es6 transpilation.
I also have problem!
windows 8.1 pro
only one index.js file in src/test
Button
√ should show the given text
√ should handle the click event2 passing (63ms)
0 passing (0ms)
But may be this small tip could be usefull: if run the same from Git Bash (for windows) everything works properly.
Windows 7, mocha 3.4.2, cmder
mocha ./test/ --compilers js:babel-core/register --compilers jsx:babel-register -w
0 passing (0ms)
upd: Git shell (from Github Desktop) don`t working.
I am a bot that watches issues for inactivity.
This issue hasn't had any recent activity, and I'm labeling it stale. In 14 days, if there are no further comments or activity, I will close this issue.
Thanks for contributing to Mocha!
not stale
having the same problem, on osx
this is my command line for running mocha:
mocha --require 'test/javascript/helpers/includes.jsx' 'test/javascript/helpers/browser' 'app/javascript/bundles/**/*.spec.jsx' --watch
if I touch the first file: test/javascript/helpers/browser tests get run, but only the first time I save, on further saves, they don't get run any more.
if I touch any of the app/javascript/bundles/**/*.spec.jsx they don't.
I've also tried with --recursive with no luck.
@UsulPro you use a symlink?
I have this problem when using symlink
2 passing (63ms)
0 passing (0ms)
Hi @DonGiulio, try adding --watch-extensions jsx and see if that fixes it.
@higimo Could you elaborate on your code's structure and how to create a symlink that will encounter this? I was under the impression that symlinks are treated the same both times, but I'd be interested to take a look at it. (And just to double-check I'm on the same page: Is this on Windows? With cmd, or another shell?)
Thanks @ScottFreeCode the --watch-extensions jsx did the trick, here's the complete command line.
mocha --watch-extensions jsx --watch --require 'test/javascript/helpers/includes.jsx' 'test/javascript/helpers/browser' 'app/javascript/bundles/**/*.spec.jsx'
I don't think this is actionable.
I have this issue on both OSX and Linux

Adding --watch-extensions ts works for me too (on osx, visual studio code) 👍
mocha -r ts-node/register test/*/.ts --reporter mochawesome --reporter-options reportDir=TestResults --watch --watch-extensions ts
Most helpful comment
For those having issues, please try passing a glob instead of the
--recursiveflag, and let me know if you have success:UPDATE: Those may need to be backslashes? Try both. Enclosing the globspec in double-quotes means that the
globmodule will parse it; otherwise your shell would (whatever it is)