Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Sandbox breaks code with QUnit because of "module" global var #91

Closed
keithamus opened this Issue · 3 comments

4 participants

@keithamus

The sandbox module inside Sinon has a tendency to break commonjs libs because of the way it checks for module.exports.

All other libs in Sinon use this code:

var commonJSModule = typeof module == "object" && typeof require == "function";
...
if (commonJSModule) {

But the Sandbox module uses this:

if (typeof module !== "undefined") {
}

This of course becomes very fragile because, for a lib like QUnit, where "module" is a global variable, Sandbox attaches itself to QUnits module function, with a property of exports. This then breaks other code as well, for example RaphaelJS, which has this:

(typeof module != "undefined" && module.exports) ? (module.exports = eve) : (glob.eve = eve);

Obviously module is defined (it's the QUnit module function) and exports is defined (from Sinon's Sandbox lib), so now RaphaelJS thinks it is in a nodejs style environment and breaks.

@cjohansen
Owner

Thanks. Fixed and pushed in 1.3.2

@cjohansen cjohansen closed this
@chrisdarroch

Related: https://gitorious.org/buster/buster-core/merge_requests/2

This issue has resurfaced in recent releases by virtue of buster-core's inclusion in to the mix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.