Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Add test for include option in banner plugin #10736

Merged
merged 2 commits into from Apr 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -18,6 +18,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