add test case

This commit is contained in:
Tim Sebastian 2017-09-25 22:11:27 +10:00
parent 9e5b7f4418
commit 06d1fb1e00
8 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,20 @@
function requireInContext(someVariable) {
return require(`./some-dir/${someVariable}`);
}
it("should not exclude paths not matching the exclusion pattern", function() {
requireInContext("file").should.be.eql("thats good");
requireInContext("check-here/file").should.be.eql("thats good");
requireInContext("check-here/check-here/file").should.be.eql("thats good");
});
it("should exclude paths/files matching the exclusion pattern", function() {
(() => requireInContext("dont")).
should.throw(/Cannot find module '.\/dont'/);
(() => requireInContext("dont-check-here/file")).
should.throw(/Cannot find module '.\/dont-check-here\/file'/);
(() => requireInContext("check-here/dont-check-here/file")).
should.throw(/Cannot find module '.\/check-here\/dont-check-here\/file'/);
});

View File

@ -0,0 +1 @@
module.exports = "thats good";

View File

@ -0,0 +1 @@
module.exports = "thats bad";

View File

@ -0,0 +1 @@
module.exports = "thats good";

View File

@ -0,0 +1 @@
module.exports = "thats bad";

View File

@ -0,0 +1 @@
module.exports = "thats bad";

View File

@ -0,0 +1 @@
module.exports = "thats good";

View File

@ -0,0 +1,7 @@
var webpack = require("../../../../");
module.exports = {
plugins: [
new webpack.ContextExclusionPlugin(/dont/)
]
};