diff options
author | Johannes Ewald <johannes.ewald@peerigon.com> | 2015-02-05 23:11:50 +0300 |
---|---|---|
committer | Johannes Ewald <johannes.ewald@peerigon.com> | 2015-02-05 23:11:50 +0300 |
commit | fb5b841fdc65ed69adcbcbf4b33d17a0f61249e5 (patch) | |
tree | 3a10e6eebe72f7a0de059ed2d8af47f6ceead69b | |
parent | b4af5ba1bb3908b3f6743bf96d867c37c399a57c (diff) |
Use mocha to check for global leaks
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | test/rewire.test.js | 8 | ||||
-rw-r--r-- | test/testModules/sharedTestCases.js | 3 |
3 files changed, 4 insertions, 9 deletions
diff --git a/package.json b/package.json index 6efa4e4..f7b7ddb 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/test/rewire.test.js b/test/rewire.test.js index 0524a36..1ac0129 100644 --- a/test/rewire.test.js +++ b/test/rewire.test.js @@ -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"); }); diff --git a/test/testModules/sharedTestCases.js b/test/testModules/sharedTestCases.js index 785b41b..20e017d 100644 --- a/test/testModules/sharedTestCases.js +++ b/test/testModules/sharedTestCases.js @@ -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 () { |