Skip to content
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

Isolation of Test scripts #1637

Closed
robcolburn opened this issue Apr 1, 2015 · 6 comments
Closed

Isolation of Test scripts #1637

robcolburn opened this issue Apr 1, 2015 · 6 comments

Comments

@robcolburn
Copy link

I have two test scripts in my tests path server-side.js and client-side.js. Both utilize React and a set of related modules for an "isomorphic" dev experience. Great. Individually, both do their thing, and tests pass. Beautiful. When I allow both to run, that is I don't comment out the other one, the server-side fails. Why, oh, why? The problem seems to stem from using React's TestUtils library on the client-side , which may be making unknown changes to the node environment (I've already gone down the road of manually setting/unsetting global.window and global.document for similar reasons). That sucks, and it's non-obvious what it's doing. So, yes, I should complain to ReactJS that they need proper tear-downs for whatever environmental modifications they are making. In the mean time though, I'd like my testing framework to be able to run these in isolation.

@dasilvacontin
Copy link
Contributor

"test": "mocha server-side.js && mocha client-side.js"?

@robcolburn
Copy link
Author

That's a good point. I love Mocha's auto pickup mechanism, and use it as boiler-plate, but nothing wrong with being explicit until a tear down fix is in place. I'll give it a shot, thanks!

@dasilvacontin
Copy link
Contributor

I believe we decided it's not mocha's fault if a library modifies the environment, that we shouldn't restore globals, etc.

Let us know if it works! (it should)

@robcolburn
Copy link
Author

Works great 👍

@dasilvacontin
Copy link
Contributor

Nice :)

@Lukenickerson
Copy link

... we decided it's not mocha's fault if a library modifies the environment ...

It might not be mocha's fault, but being able to run isolated tests is a critical feature of testing (especially unit testing), so it is sorely missed. Other testing frameworks like AVA have process isolation, so it is certainly a strange decision for mocha not to support some way to do this (even if as a non-default option).

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

No branches or pull requests

3 participants