Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfb5b841

Browse files
committed
Use mocha to check for global leaks
1 parentb4af5ba commitfb5b841

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"mocha":"^2.1.0"
3434
},
3535
"scripts": {
36-
"test":"node node_modules/mocha/bin/mocha -R spec",
36+
"test":"mocha -R spec --check-leaks",
3737
"coverage":"istanbul cover ./node_modules/mocha/bin/_mocha"
3838
}
3939
}

‎test/rewire.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ describe("rewire", function () {
1616
fs.renameSync(fakeNodeModules,path.resolve(__dirname,"testModules/node_modules"));
1717
}
1818
});
19-
it("should keep not leak globals",function(){
20-
// This test should run first, as the global space may be already polluted if
21-
// require("../") is run before this test.
22-
varoriginalGlobalKeys=Object.keys(global),
23-
rewire=require("../"),
24-
emptyModule=rewire("./testModules/emptyModule.js");
25-
expect(Object.keys(global)).to.eql(originalGlobalKeys);
26-
});
2719
it("should pass all shared test cases",function(){
2820
require("./testModules/sharedTestCases.js");
2921
});

‎test/testModules/sharedTestCases.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,9 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
256256
// setting implicit global vars will change them globally instead of locally.
257257
// that's a shortcoming of the current implementation which can't be solved easily.
258258
//expect(implicitGlobal).to.be.a("string");
259+
260+
// Cleaning up...
261+
deleteglobal.implicitGlobal;
259262
});
260263

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp