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.
"test": "mocha server-side.js && mocha client-side.js"?
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!
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)
Works great :+1:
Nice :)
... 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).
Most helpful comment
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).