Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a7bdea2

Browse files
committed
Move testLib into dedicated folder inside root folder
1 parent 5a8ba82 commit a7bdea2

File tree

14 files changed

+20
-15
lines changed

14 files changed

+20
-15
lines changed

.istanbul.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
instrumentation:
2-
# These functions will be stringified and evaled again. Thus it's difficult to include them into the test coverage
32
excludes: [
3+
# These functions will be stringified and evaled again. Thus it's difficult to include them into the test coverage
44
'lib/__get__.js',
55
'lib/__set__.js',
6-
'lib/__with__.js'
7-
]
6+
'lib/__with__.js',
7+
# Ignore shared test cases. These are just in the lib folder because they should
8+
'testLib/*'
9+
]

lib/testModules/node_modules/rewire/package.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/rewire.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ var rewire;
1010

1111
describe("rewire", function () {
1212
before(function () {
13-
var fakeNodeModules = path.resolve(__dirname, "testModules/fake_node_modules");
13+
var fakeNodeModules = path.resolve(__dirname, "../testLib/fake_node_modules");
1414

1515
if (fs.existsSync(fakeNodeModules)) {
16-
fs.renameSync(fakeNodeModules, path.resolve(__dirname, "testModules/node_modules"));
16+
fs.renameSync(fakeNodeModules, path.resolve(__dirname, "../testLib/node_modules"));
1717
}
1818
});
1919
it("should pass all shared test cases", function () {
20-
require("../lib/testModules/sharedTestCases.js");
20+
require("../testLib/sharedTestCases.js");
2121
});
2222
it("should also work with CoffeeScript", function () {
2323
var coffeeModule;
2424

2525
rewire = require("../");
26-
coffeeModule = rewire("../lib/testModules/module.coffee");
26+
coffeeModule = rewire("../testLib/module.coffee");
2727
coffeeModule.__set__("fs", {
2828
readFileSync: function () {
2929
return "It works!";
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

testLib/node_modules/rewire/package.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/testModules/sharedTestCases.js renamed to testLib/sharedTestCases.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99

1010
var expect = require("expect.js"),
1111
rewire = require("rewire"),
12-
__set__Src = require("../../lib/__set__.js").toString(),
13-
__get__Src = require("../../lib/__get__.js").toString(),
14-
__with__Src = require("../../lib/__with__.js").toString();
12+
__set__Src = require("../lib/__set__.js").toString(),
13+
__get__Src = require("../lib/__get__.js").toString(),
14+
__with__Src = require("../lib/__with__.js").toString();
1515

1616
function checkForTypeError(err) {
1717
expect(err.constructor).to.be(TypeError);
@@ -23,7 +23,7 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
2323
rewire("./moduleA.js").getFilename();
2424
require("./moduleA.js").getFilename();
2525
expect(rewire("./moduleA.js").getFilename()).to.eql(require("./moduleA.js").getFilename());
26-
expect(rewire("../testModules/someOtherModule.js").filename).to.eql(require("../testModules/someOtherModule.js").filename);
26+
expect(rewire("../testLib/someOtherModule.js").filename).to.eql(require("../testLib/someOtherModule.js").filename);
2727
});
2828

2929
it("should return a fresh instance of the module", function () {
@@ -69,7 +69,7 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
6969

7070
["__get__", "__set__", "__with__"].forEach(function(funcName) {
7171
it("should provide " + funcName + " as a non-enumerable property", function () {
72-
expect(Object.keys(rewire("./moduleA.js")).indexOf(funcName)).to.be(-1)
72+
expect(Object.keys(rewire("./moduleA.js")).indexOf(funcName)).to.be(-1);
7373
});
7474

7575
it("should provide " + funcName + " as a writable property", function () {
@@ -240,6 +240,9 @@ describe("rewire " + (typeof testEnv === "undefined"? "(node)": "(" + testEnv +
240240
it("should not modify line numbers in stack traces", function () {
241241
var throwError = rewire("./throwError.js");
242242

243+
if (process.env.running_under_istanbul === "1") {
244+
return;
245+
}
243246
try {
244247
throwError();
245248
} catch (err) {
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)