add test case

This commit is contained in:
Tobias Koppers 2021-01-13 12:45:22 +01:00
parent f72b803ed6
commit 684d375541
11 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1 @@
module.exports = '0';

View File

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

View File

@ -0,0 +1 @@
module.exports = "is only ";

View File

@ -0,0 +1 @@
module.exports = "a test";

View File

@ -0,0 +1,10 @@
it("should watch for changes", function () {
if (+WATCH_STEP !== 3) expect(require("./delayed")).toBe(WATCH_STEP);
else expect(require("./delayed")).toBe("This is only a test." + WATCH_STEP);
if (+WATCH_STEP > 0) {
for (var m of STATS_JSON.modules.filter(m =>
/(a|b|c)\.js$/.test(m.identifier)
))
expect(m.issuer).toBe(null);
}
});

View File

@ -0,0 +1 @@
module.exports = '1';

View File

@ -0,0 +1 @@
module.exports = '2';

View File

@ -0,0 +1,5 @@
var a = require("./a");
var b = require("./b");
var c = require("./c");
module.exports = a + b + c + '.3';

View File

@ -0,0 +1,9 @@
module.exports = function (source) {
expect(source).toMatch(/^\}\)\]/);
this.cacheable(false);
return new Promise(resolve => {
setTimeout(() => {
resolve("module.exports = require('./foo/' + WATCH_STEP);");
}, 500);
});
};

View File

@ -0,0 +1,15 @@
const path = require("path");
const webpack = require("../../../../");
/** @type {import("../../../../").Configuration} */
module.exports = {
module: {
rules: [
{
test: /delayed/,
use: path.resolve(__dirname, "./delayed")
}
]
},
plugins: [new webpack.AutomaticPrefetchPlugin()]
};