grunt-simple-mocha icon indicating copy to clipboard operation
grunt-simple-mocha copied to clipboard

Fixes #18

Open vseventer opened this issue 12 years ago • 5 comments

By default, a call to require(module) will cache module. This however causes simple-mocha tests to be executed only once when run multiple times (e.g. as part of a regarde/watch task). This fix will delete the test modules from the require() cache prior to each run.

Also see #18.

vseventer avatar Apr 03 '13 15:04 vseventer

Nice! It actually occured to me this morning that this might be the issue, but I hadn't gotten to look into it. Thanks!

joeybaker avatar Apr 04 '13 21:04 joeybaker

Can you do this in one of grunt-regarde's events?

I feel like it's the watch task's job to ensure that the process's require cache is clean (or at least to provide hooks as they have done here).

yaymukund avatar Apr 09 '13 03:04 yaymukund

The watch task was just an example; running grunt simplemocha simplemocha will result in the same behavior. I feel running the same test suite twice should yield the same results. It should be the test's task job to make sure the tests actually run correctly.

vseventer avatar Apr 09 '13 13:04 vseventer

Seems like my solution doesn't take nested require()s into account.

This can be supported by obtaining the pre-require and post-require caches, and delete the difference set. This works as a quick solution, yet I'm hoping someone can come up with a better way.

vseventer avatar Apr 09 '13 21:04 vseventer

Here is it :) https://github.com/visionmedia/mocha/issues/445#issuecomment-17693393

steida avatar May 09 '13 22:05 steida