Skip to content

Commit

Permalink
test: more
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Apr 29, 2023
1 parent c348c66 commit ce7c6cb
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/build/extends/extends.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ describe("extends property", () => {
expect(stdout).toContain("topLevelAwait: true");
});

it("extends a provided webpack config for multiple configs correctly #2", async () => {
const { exitCode, stderr, stdout } = await run(__dirname + "/multiple-configs2");

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("base.webpack.config.js");
expect(stdout).toContain("derived.webpack.config.js");
expect(stdout).toContain("name: 'base_config'");
expect(stdout).toContain("name: 'derived_config2'");
expect(stdout).toContain("mode: 'development'");
expect(stdout).toContain("topLevelAwait: true");
});

it("multiple extends a provided webpack config passed in the cli correctly", async () => {
const { exitCode, stderr, stdout } = await run(__dirname + "/extends-cli-option", [
"--extends",
Expand All @@ -70,6 +83,24 @@ describe("extends property", () => {
expect(stdout).toContain("bail: true");
});

it("should work with multiple extends and multiple configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname + "/multiple-configs1", [
"--extends",
"./base.webpack.config.js",
"--extends",
"./other.config.js",
]);

expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain("derived.webpack.config.js");
expect(stdout).toContain("base.webpack.config.js");
expect(stdout).toContain("other.config.js");
expect(stdout).toContain("name: 'derived_config1'");
expect(stdout).toContain("name: 'derived_config2'");
expect(stdout).toContain("topLevelAwait: true");
});

it("CLI `extends` should override `extends` in a configuration", async () => {
const { exitCode, stderr, stdout } = await run(__dirname + "/simple-case", [
"--extends",
Expand Down
11 changes: 11 additions & 0 deletions test/build/extends/multiple-configs/other.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = () => {
console.log("other.config.js");

return {
name: "other_config",
mode: "development",
experiments: {
topLevelAwait: true,
},
};
};
15 changes: 15 additions & 0 deletions test/build/extends/multiple-configs1/base.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");

module.exports = () => {
console.log("base.webpack.config.js");

return {
name: "base_config",
mode: "development",
plugins: [new WebpackCLITestPlugin()],

experiments: {
topLevelAwait: true,
},
};
};
11 changes: 11 additions & 0 deletions test/build/extends/multiple-configs1/other.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = () => {
console.log("other.config.js");

return {
name: "other_config",
mode: "development",
experiments: {
topLevelAwait: true,
},
};
};
1 change: 1 addition & 0 deletions test/build/extends/multiple-configs1/src/index1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("i am index1.js");
1 change: 1 addition & 0 deletions test/build/extends/multiple-configs1/src/index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("i am index2.js");
14 changes: 14 additions & 0 deletions test/build/extends/multiple-configs1/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = () => {
console.log("derived.webpack.config.js");

return [
{
name: "derived_config1",
entry: "./src/index1.js",
},
{
name: "derived_config2",
entry: "./src/index2.js",
},
];
};
16 changes: 16 additions & 0 deletions test/build/extends/multiple-configs2/base.webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");

module.exports = () => {
console.log("base.webpack.config.js");

return {
entry: "./src/index1.js",
name: "base_config",
mode: "development",
plugins: [new WebpackCLITestPlugin()],

experiments: {
topLevelAwait: true,
},
};
};
1 change: 1 addition & 0 deletions test/build/extends/multiple-configs2/src/index1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("i am index1.js");
1 change: 1 addition & 0 deletions test/build/extends/multiple-configs2/src/index2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("i am index2.js");
17 changes: 17 additions & 0 deletions test/build/extends/multiple-configs2/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");

module.exports = () => {
console.log("derived.webpack.config.js");

return [
{
extends: "./base.webpack.config.js",
},
{
name: "derived_config2",
mode: "development",
entry: "./src/index2.js",
plugins: [new WebpackCLITestPlugin()],
},
];
};

0 comments on commit ce7c6cb

Please sign in to comment.