mirror of https://github.com/webpack/webpack.git
add test case
This commit is contained in:
parent
9e5b7f4418
commit
06d1fb1e00
|
|
@ -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'/);
|
||||
});
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats good";
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats bad";
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats good";
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats bad";
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats bad";
|
||||
|
|
@ -0,0 +1 @@
|
|||
module.exports = "thats good";
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
var webpack = require("../../../../");
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
new webpack.ContextExclusionPlugin(/dont/)
|
||||
]
|
||||
};
|
||||
Loading…
Reference in New Issue