Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Allow disabling of global detections #15

Closed
3rd-Eden opened this issue Nov 29, 2013 · 12 comments
Closed

Allow disabling of global detections #15

3rd-Eden opened this issue Nov 29, 2013 · 12 comments

Comments

@3rd-Eden
Copy link

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 the zuul.yml file.

@defunctzombie
Copy link
Owner

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.

@3rd-Eden
Copy link
Author

3rd-Eden commented Dec 2, 2013

@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 :)

@defunctzombie
Copy link
Owner

Not without forking zuul and changing the hardcoded option in the setup
file. I am open to making it a config option tho I kinda feel it falls
under the realm of test framework but maybe zuul should have a ui-options
field in the yaml where some general things can be configured like this and
overall timeouts. Yea, I think I will add that.

Do your globals persist between tests? If they dont, then you could delete
them from the global object before the test ends as a quick hack.
On Dec 2, 2013 6:52 AM, "Arnout Kazemier" notifications@github.com wrote:

@defunctzombie https://github.com/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 :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/15#issuecomment-29612056
.

@3rd-Eden
Copy link
Author

3rd-Eden commented Dec 2, 2013

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

@defunctzombie
Copy link
Owner

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


Reply to this email directly or view it on GitHub.

@3rd-Eden
Copy link
Author

3rd-Eden commented Dec 2, 2013

Every browser has that problem: https://saucelabs.com/tests/f69cc7dd63cb4cdf8cb606dc7013015b even when I run it locally, it doesn't want to remove it.

@defunctzombie
Copy link
Owner

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:
https://github.com/defunctzombie/zuul/blob/master/frameworks/mocha/post.js#L3

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.


Reply to this email directly or view it on GitHub.

@eshao
Copy link
Contributor

eshao commented Dec 10, 2013

As a workaround, you can do something like this in your test file:

 13   if (global.mocha) {
 14     global.mocha.timeout(9000)
 15     global.mocha.checkLeaks = false
 16   }

Where global is your window variable.

@defunctzombie
Copy link
Owner

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.

@3rd-Eden
Copy link
Author

The work around suggest doesn't work.

@3rd-Eden
Copy link
Author

Nevermind, my code is obviously failing.

@defunctzombie
Copy link
Owner

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.

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

No branches or pull requests

3 participants