-
Notifications
You must be signed in to change notification settings - Fork 61
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
Unable to run the suites twice (with different configuration) #108
Comments
I'll take a look, but I'm not sure I understand the workaround. Also, usually, different tasks use different tests so reusing the mocha instance would break that use case. I don't think this will be trivial |
I currently don't have enough time to look into code, unfortunately, but maybe the reason is that different tasks are indeed using the same mocha instance. |
No, it's to do with the way mocha includes tests. It loads them using require, which results in Node putting them in the require cache. Thus the second Mocha instance does that, but as it's in the same Node process, any file previously loaded does not get loaded again and the tests don't get added. If you reuse the same mocha object then the tests are already loaded and you can run them again (possibly with different environment variables). As you can tell I had time to think about this and now understand how the workaround works. You would still have issues with any environment dependent code run outside of a describe block as it would not run twice, but i think anything inside a callback would be run again. At the very least anything inside Still the problem remains - reusing the Mocha instance will break the use case of having different tests in different grunt tasks. I still have to think some more. I'm wondering if i can make it cache the instance for each task - so if you actually run the same task then it will use the same instance, but different tasks use different instances. You could then adjust the grunt config thus:
This assumes grunt doesn't get too clever and only run the task once, thinking it already did it. I don't think that will happen, but I can see that you will have issues specifying different options (ie. the capture file) |
Unfortunately, both of those mocha tasks are part of my versioning task, and I definitely need them both in the same process, just to validate that my application supports legacy configuration before increasing the version number. |
Currently it's impossible to run the tests twice. The second pass just claims that there are no suites to run.
Here is mochaTest config example:
Here is the piece of
grunt testAll
output:I believe it's related with this issue. Is it possible to do something like this, after all suites has been runned?
The text was updated successfully, but these errors were encountered: