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

Remove invalid optimization in checkGlobals(). #1110

Merged
merged 1 commit into from
Jan 21, 2014

Conversation

noshir-patel
Copy link
Contributor

fixes #1015

There was an attempt at an optimization in checkGlobals that would short circuit globals checking if the number of tolerated globals was equal (correcting for a couple of expected differences) to the number of actual globals. This is completely invalid since you could tolerate a new global in your mocha config and the system under test could add a different global but not the new global you are tolerating. (Or you could tolerate two new ones, and two new unexpected ones could be added by the system under test, etc.) In these cases, the unexpected globals will not be reported by mocha and tests will pass when they should not. So basically the code was assuming that the system under test would DEFINITELY add any globals that were added to the list of tolerated globals through mocha config.

I added a test for the simplest failure case, saw it fail, and then removed the offending code.

travisjeffery added a commit that referenced this pull request Jan 21, 2014
Remove invalid optimization in checkGlobals().
@travisjeffery travisjeffery merged commit afd3c3d into mochajs:master Jan 21, 2014
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

Successfully merging this pull request may close these issues.

How is mocha.globals supposed to work?
2 participants