Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Fixes #18 #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fixes #18 #30

wants to merge 1 commit into from

Conversation

vseventer
Copy link

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.

@joeybaker
Copy link

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

@yaymukund
Copy link
Owner

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).

@vseventer
Copy link
Author

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
Copy link
Author

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.

@steida
Copy link

steida commented May 9, 2013

Here is it :)
mochajs/mocha#445 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants