mocha-webpack icon indicating copy to clipboard operation
mocha-webpack copied to clipboard

--watch only watches files in test directory

Open hgascoigne opened this issue 6 years ago • 4 comments

Running [email protected] and [email protected], using the --watch option only seems to watch for changes in my /test directory, but not when I make changes to files in other directories like /src.

Here is the command I am running:

mocha-webpack --webpack-config build/webpack.test.config.js --require ./test/bootstrap.js test/**/*.spec.js

Modifying src/runner/TestRunner.js from:

const watcher = chokidar.watch(this.entries, {
  ...
});

to:

const watcher = chokidar.watch('.', {
  ...
});

resolves this issue for me, but I'm not familiar enough with the inner workings of this project to know what the real issue is. Having chokidar watch all files in the CWD is definitely a brute force method to get this working. Could there be something with my configuration that is incorrect, or is anyone else experiencing the same issue?

hgascoigne avatar Apr 30 '18 17:04 hgascoigne

This is happening to me as well, with a simpler: mocha-webpack \"test/**/*.spec.js\".

Same version of mocha-webpack and webpack, though. I don't remember this being a problem across the last year of using it; so it feels like a bug introduced either by the new beta changes or a change in the way Webpack 4 behaves with entires.

thomasmichaelwallace avatar May 01 '18 14:05 thomasmichaelwallace

I am not sure if this is related, but I use the watch mode to fix failing tests. When I fix the source code, the testing reruns, but very cleverly bypasses the previously failed tests giving me an illusion I fixed everything. So you would want to also add every previously failing test as if it was changed every time.

romanzenka avatar Jun 28 '18 14:06 romanzenka

Did anyone find a resolution to this issue? I'm using [email protected] and it seems to only be watching the test files. It will not re-run the tests if I change my source files.

camposfyi avatar May 19 '19 04:05 camposfyi

Apparently no solution was found

Bogdan808 avatar Mar 02 '20 16:03 Bogdan808