Skip to content

Commit

Permalink
Use mocha to check for global leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Feb 5, 2015
1 parent b4af5ba commit fb5b841
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"mocha": "^2.1.0"
},
"scripts": {
"test": "node node_modules/mocha/bin/mocha -R spec",
"test": "mocha -R spec --check-leaks",
"coverage": "istanbul cover ./node_modules/mocha/bin/_mocha"
}
}
8 changes: 0 additions & 8 deletions test/rewire.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ describe("rewire", function () {
fs.renameSync(fakeNodeModules, path.resolve(__dirname, "testModules/node_modules"));
}
});
it("should keep not leak globals", function () {
// This test should run first, as the global space may be already polluted if
// require("../") is run before this test.
var originalGlobalKeys = Object.keys(global),
rewire = require("../"),
emptyModule = rewire("./testModules/emptyModule.js");
expect(Object.keys(global)).to.eql(originalGlobalKeys);
});
it("should pass all shared test cases", function () {
require("./testModules/sharedTestCases.js");
});
Expand Down
3 changes: 3 additions & 0 deletions test/testModules/sharedTestCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,9 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
// setting implicit global vars will change them globally instead of locally.
// that's a shortcoming of the current implementation which can't be solved easily.
//expect(implicitGlobal).to.be.a("string");

// Cleaning up...
delete global.implicitGlobal;
});

it("should throw a TypeError if the path is not a string", function () {
Expand Down

0 comments on commit fb5b841

Please sign in to comment.