-
Notifications
You must be signed in to change notification settings - Fork 86
Allow disabling of global detections #15
Comments
I have a pull request out to mocha (mochajs/mocha#1046) which will allow per test global whitelisting. This is better than outright disabling global detection since it will still allow you to benefit from global detection in other tests. This came up in testing engine.io-client on older browsers which also introduces globals on purpose. I have been back and forth on how to introduce some of the other options via the config file (or if I even should) but haven't thought of a good name for it yet. Suggestions would be welcome! I held off on it since the goal is to work with minimal thought and just focus on writing tests. |
@defunctzombie yes, per test whitelisting would be great. But is there a way to turn global detection off completely now? As all my tests are failing which makes it quite hard to do regression testing this way :) |
Not without forking zuul and changing the hardcoded option in the setup Do your globals persist between tests? If they dont, then you could delete
|
I actually try to destroy it when the test ends, but it seems that you cannot delete them from the global object; https://github.com/3rd-Eden/fortress/blob/master/test.js#L102-L104 |
Is that failing in IE? On December 2, 2013 at 10:27:18 AM, Arnout Kazemier (notifications@github.com) wrote: I actually try to destroy it when the test ends, but it seems that you cannot delete them from the global object; https://github.com/3rd-Eden/fortress/blob/master/test.js#L102-L104 — |
Every browser has that problem: https://saucelabs.com/tests/f69cc7dd63cb4cdf8cb606dc7013015b even when I run it locally, it doesn't want to remove it. |
So global leaks in mocha are weird because they are not actually a config option like timeout, etc. They are set via separate function call. See if this works for you fork zuul and remove this line: This will at least get your tests running. The real issue here is how mocha has leak setup. I will see what is holding up merging that pull request I have for per test globals which will solve some of these issues. On December 2, 2013 at 10:31:36 AM, Arnout Kazemier (notifications@github.com) wrote: Every browser has that problem: https://saucelabs.com/tests/f69cc7dd63cb4cdf8cb606dc7013015b even when I run it locally, it doesn't want to remove it. — |
As a workaround, you can do something like this in your test file:
Where global is your window variable. |
I am wondering if checking for global leaks is even something that should be on by default. IMO I think it is very useful. Maybe just documenting the workaround as the way to disable is enough. |
The work around suggest doesn't work. |
Nevermind, my code is obviously failing. |
Closing. The latest mocha we ship with zuul now supports the .globals method on your test runner (within your test). So you should be able to whitelist globals for specific tests. |
I'm using
mocha
as test interface and it has global detection turned on by default. My library fortress is actually introducing globals as part of it's tests. It would be nice if these testing frameworks's options could be set through thezuul.yml
file.The text was updated successfully, but these errors were encountered: