-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Bug: Mocha stores instance state in shared global space - ie. the require cache #1938
Comments
Agreed, this is really bad design and should be fixed. |
+1 Edit: The following code works for me. It is possible to remove the test files manually from cache.
Edit2: Btw, the fields below are present in global space after first run. With a VM, these fields could be attached to a context that is available in a test file, but not in the main execution script.
|
I am a bot that watches issues for inactivity. |
Poke |
Related: #2706 |
This is reflected in #995 and pghalliday/grunt-mocha-test#108, and many other issues that keep cropping up with watch tasks even though I keep telling people to rerun tests in new processes and not reuse the same process (admittedly this pattern has other problems too)
Basically, you cannot create a new instance of mocha and add the same test files as a previously created instance. This is because
require
is used to run the test files and when you require them again they hit the require cache and don't run (ie. they fail to register their tests).IMHO this is a bad design choice as instance state should not be dependent on the global state of the require cache. I suggest that
addFile
be changed to actually load and evaluate the file and not depend onrequire
.Rant over ;)
The text was updated successfully, but these errors were encountered: