Skip to content

Commit

Permalink
Merge pull request #10736 from jeffin143/test-bannerplugin
Browse files Browse the repository at this point in the history
Test: Add test for include option in banner plugin
  • Loading branch information
TheLarkInn committed Apr 14, 2023
2 parents 124a6a2 + 2026b46 commit 671ac29
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/configCases/plugins/banner-plugin/index.js
Expand Up @@ -13,11 +13,15 @@ it("should contain banner in bundle0 chunk", () => {
expect(source).toMatch(
"/*!\n * trim trailing whitespace\n *\n * no trailing whitespace\n */"
);
expect(source).not.toMatch(new RegExp("^/*! A test value in single file */$"));
expect(source).not.toMatch(new RegExp("^/*! Match test file */$"));
});

it("should not contain banner in vendors chunk", () => {
const source = fs.readFileSync(path.join(__dirname, "vendors.js"), "utf-8");
expect(source).not.toMatch("A test value");
expect(source).not.toMatch("/*! A test value */");
expect(source).toMatch("/*! A test value in single file */");
expect(source).toMatch("/*! Match test file */");
});

if (Math.random() < 0) require("./test.js");
8 changes: 8 additions & 0 deletions test/configCases/plugins/banner-plugin/webpack.config.js
Expand Up @@ -19,6 +19,14 @@ module.exports = {
banner: "A test value",
exclude: ["vendors.js"]
}),
new webpack.BannerPlugin({
banner: "A test value in single file",
include: ["vendors.js"]
}),
new webpack.BannerPlugin({
banner: "Match test file",
test: /vendors\.js$/
}),
new webpack.BannerPlugin({
banner: ({ chunk }) => `multiline\nbanner\n${chunk.name}`
}),
Expand Down

0 comments on commit 671ac29

Please sign in to comment.