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

errorMessage leaked to global scope in non-strict mode, ReferenceError in strict mode #1034

Closed
ScottFreeCode opened this issue Aug 28, 2017 · 1 comment

Comments

@ScottFreeCode
Copy link

If I run node --use_strict -e 'require("chai").expect("42").to.be.above(0)' I get:

ReferenceError: errorMessage is not defined

Instead of:

AssertionError: expected '42' to be a number or a date

If I run node -e 'try { require("chai").expect("42").to.be.above(0) } catch (ignore) { require("chai").expect(global.errorMessage).to.be.undefined }'

I get:

AssertionError: expected 'expected '42' to be a number or a date' to be undefined


There are probably other cases of variables being used without declaration; this just happens to be the one I ran into. Using --use_strict or --check-leaks in Mocha testing can help spot these, by the way!

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

No branches or pull requests

2 participants