Skip to content

Commit 06d1fb1

Browse files
committed
add test case
1 parent 9e5b7f4 commit 06d1fb1

File tree

8 files changed

+33
-0
lines changed

8 files changed

+33
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
function requireInContext(someVariable) {
2+
return require(`./some-dir/${someVariable}`);
3+
}
4+
5+
it("should not exclude paths not matching the exclusion pattern", function() {
6+
requireInContext("file").should.be.eql("thats good");
7+
requireInContext("check-here/file").should.be.eql("thats good");
8+
requireInContext("check-here/check-here/file").should.be.eql("thats good");
9+
});
10+
11+
it("should exclude paths/files matching the exclusion pattern", function() {
12+
(() => requireInContext("dont")).
13+
should.throw(/Cannot find module '.\/dont'/);
14+
15+
(() => requireInContext("dont-check-here/file")).
16+
should.throw(/Cannot find module '.\/dont-check-here\/file'/);
17+
18+
(() => requireInContext("check-here/dont-check-here/file")).
19+
should.throw(/Cannot find module '.\/check-here\/dont-check-here\/file'/);
20+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats good";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats bad";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats good";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats bad";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats bad";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "thats good";
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
var webpack = require("../../../../");
2+
3+
module.exports = {
4+
plugins: [
5+
new webpack.ContextExclusionPlugin(/dont/)
6+
]
7+
};

0 commit comments

Comments
 (0)