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:
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.
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:
But the Sandbox module uses this:
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:
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.