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

Watch and always run entire suite?

Open adamclerk opened this issue 8 years ago • 13 comments

Is there an option for this already built in?

adamclerk avatar Feb 23 '17 21:02 adamclerk

No, I thought about it a long time ago but came to the conclusion that there isn't any benefit. Why do you need this?

mocha-webpack detects file changes and all files that were affected by a file change, especially in the latest beta. The latest non-beta (0.7.0) has some issues in the detection.

zinserjan avatar Feb 25 '17 08:02 zinserjan

Still have some issue with file change, sometimes some tests are not re-run. Some co-workers are not using watch anymore... (with v1.0.0-beta.1 and our 700 tests)

serut avatar Apr 11 '17 14:04 serut

@zinserjan one issue we've seen is that a code change will break dependent files. When we fix the dependent file/test we lose context of all the other breakages.

Say: b.js and c.js import a.js. If I make a change to a.js that causes breakage to b.js and c.js fixing one will cause me to lose the context of the other.

I don't have a good solution other than disable interactive (which is what we do).

I totally get not wanting to run the whole suite (that's the point of watching with webpack's help) but it would be nice for it to re-run whatever is needed (according to webpack) plus any failures from the previous run not already in the webpack set.

Does that make sense?

castrog avatar Apr 17 '17 19:04 castrog

@castrog Yep, that would make sense. I also thought about this a long time ago... The only problem that I see that we need to know which test files failed before. At the moment we have only the information that something failed, but not which file exactly.

Question is, how can we detect which test files failed?

@serut Do you have the same issue like @castrog or is it something else?

zinserjan avatar Apr 19 '17 11:04 zinserjan

@zinserjan could we do it through a pass-through reporter or something like that? I'm not very familiar with the mocha codebase but seems like the file is there, right? (https://github.com/mochajs/mocha/blob/master/lib/test.js#L49)

castrog avatar Apr 26 '17 15:04 castrog

Yes that looks good, but I would expect that the file is the same for all tests cause mocha uses the webpack output bundle... I don't have any idea at the moment to get around this :smile:

zinserjan avatar Apr 26 '17 18:04 zinserjan

Could we not use the source map for that? I can understand if the webpack config doesn't use a source map then this whole process wouldn't be attempted but if it's there we should be able to do it, no?

Mocha also seems to know where the failure happened if source maps are configured so I wonder if the file is already mapped if the source map is setup.

castrog avatar Apr 27 '17 00:04 castrog

Good reason for rerunning some files: before/afterEach hooks. Related issue: https://github.com/zinserjan/mocha-webpack/issues/166

But i would say that monkey-patching beforeEach or hooking to some events of mocha will make it possible to rerun the before-each and after-each bits

antitoxic avatar Jul 20 '17 12:07 antitoxic

@zinserjan what do you think about this? Is this something you might tackle?

castrog avatar Aug 02 '17 18:08 castrog

There is a valid use case for this. If some of my spec files fail, and I start working on one spec file until all the tests in it pass... The mocha-webpack output after the fact reports as if all the tests are passing (which they are, but only in that file).

To get back and see the bigger picture again I have to kill the process and run it again or touch the failing files to trigger a reload where they will be re-run.

An option to always re-run the suite sounds like a good idea.

derekdon avatar Aug 03 '17 16:08 derekdon

mocha-webpack detects file changes and all files that were affected by a file change, especially in the latest beta. The latest non-beta (0.7.0) has some issues in the detection.

While this is technically a nice feature in some scenarios, it will often times confuse users rather than providing the actual benefit. I saw the magic going on and immediately was like "what is wrong with my test setup".

In the spirit of don't make me think can't we make predictable re-runs of the whole suite the default? The current way of selectively re-running of only change-related files could be opt-in for those who benefit from it, because they have massive test suites.

nikku avatar Oct 09 '17 12:10 nikku

If there was a way to reliably cause mocha-webpack to trigger a complete re-run, would that satisfy most users? Something like sending a signal -- e.g. kill SIGHUP -- or touching a specific file?

Some prior art: I typically don't use mocha --watch because it's buggy and rely on nodemon instead, which supports entering a rs in the active thread to restart the monitored process (I think it also responds to SIGHUP to restart). I've also used nodemon watching the config file paired with karma watching the test files so that I could just touch the config to re-start karma (which tends to crash). I can confirm that touch-ing the config files for either mocha or webpack do NOT trigger a re-run currently. Is there another file that I could try?

al-the-x avatar Nov 22 '17 16:11 al-the-x

Any update on this? I'm missing this feature with my use-case as well

bndnio avatar Apr 21 '18 00:04 bndnio