add test case

This commit is contained in:
Tobias Koppers 2020-09-20 19:44:25 +02:00
parent 1b07821739
commit ec0687b575
7 changed files with 40 additions and 0 deletions

View File

@ -0,0 +1,3 @@
import "./loader!package";
it("should compile and run the test in config", () => {});

View File

@ -0,0 +1,6 @@
const path = require("path");
module.exports = function (source) {
this.addDependency(path.resolve(__dirname, "node_modules/package/extra.js"));
this.addDependency(path.resolve(__dirname, "extra.js"));
return source;
};

View File

@ -0,0 +1,4 @@
{
"name": "package",
"version": "1.0.0"
}

View File

@ -0,0 +1,27 @@
const path = require("path");
/** @type {import("../../../../").Configuration} */
module.exports = {
snapshot: {
managedPaths: [path.resolve(__dirname, "node_modules")]
},
plugins: [
compiler => {
compiler.hooks.done.tap("Test", ({ compilation }) => {
const fileDeps = Array.from(compilation.fileDependencies);
expect(fileDeps).toContain(
path.resolve(__dirname, "node_modules/package/index.js")
);
expect(fileDeps).toContain(
path.resolve(__dirname, "node_modules/package/extra.js")
);
expect(fileDeps).toContain(
path.resolve(__dirname, "node_modules/package/package.json")
);
expect(fileDeps).toContain(path.resolve(__dirname, "extra.js"));
expect(fileDeps).toContain(path.resolve(__dirname, "loader.js"));
expect(fileDeps).toContain(path.resolve(__dirname, "index.js"));
});
}
]
};