Skip to content

Commit ce7c6cb

Browse files
test: more
1 parent c348c66 commit ce7c6cb

File tree

11 files changed

+119
-0
lines changed

11 files changed

+119
-0
lines changed

test/build/extends/extends.test.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ describe("extends property", () => {
5252
expect(stdout).toContain("topLevelAwait: true");
5353
});
5454

55+
it("extends a provided webpack config for multiple configs correctly #2", async () => {
56+
const { exitCode, stderr, stdout } = await run(__dirname + "/multiple-configs2");
57+
58+
expect(exitCode).toBe(0);
59+
expect(stderr).toBeFalsy();
60+
expect(stdout).toContain("base.webpack.config.js");
61+
expect(stdout).toContain("derived.webpack.config.js");
62+
expect(stdout).toContain("name: 'base_config'");
63+
expect(stdout).toContain("name: 'derived_config2'");
64+
expect(stdout).toContain("mode: 'development'");
65+
expect(stdout).toContain("topLevelAwait: true");
66+
});
67+
5568
it("multiple extends a provided webpack config passed in the cli correctly", async () => {
5669
const { exitCode, stderr, stdout } = await run(__dirname + "/extends-cli-option", [
5770
"--extends",
@@ -70,6 +83,24 @@ describe("extends property", () => {
7083
expect(stdout).toContain("bail: true");
7184
});
7285

86+
it("should work with multiple extends and multiple configuration", async () => {
87+
const { exitCode, stderr, stdout } = await run(__dirname + "/multiple-configs1", [
88+
"--extends",
89+
"./base.webpack.config.js",
90+
"--extends",
91+
"./other.config.js",
92+
]);
93+
94+
expect(exitCode).toBe(0);
95+
expect(stderr).toBeFalsy();
96+
expect(stdout).toContain("derived.webpack.config.js");
97+
expect(stdout).toContain("base.webpack.config.js");
98+
expect(stdout).toContain("other.config.js");
99+
expect(stdout).toContain("name: 'derived_config1'");
100+
expect(stdout).toContain("name: 'derived_config2'");
101+
expect(stdout).toContain("topLevelAwait: true");
102+
});
103+
73104
it("CLI `extends` should override `extends` in a configuration", async () => {
74105
const { exitCode, stderr, stdout } = await run(__dirname + "/simple-case", [
75106
"--extends",
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = () => {
2+
console.log("other.config.js");
3+
4+
return {
5+
name: "other_config",
6+
mode: "development",
7+
experiments: {
8+
topLevelAwait: true,
9+
},
10+
};
11+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2+
3+
module.exports = () => {
4+
console.log("base.webpack.config.js");
5+
6+
return {
7+
name: "base_config",
8+
mode: "development",
9+
plugins: [new WebpackCLITestPlugin()],
10+
11+
experiments: {
12+
topLevelAwait: true,
13+
},
14+
};
15+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = () => {
2+
console.log("other.config.js");
3+
4+
return {
5+
name: "other_config",
6+
mode: "development",
7+
experiments: {
8+
topLevelAwait: true,
9+
},
10+
};
11+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("i am index1.js");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("i am index2.js");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = () => {
2+
console.log("derived.webpack.config.js");
3+
4+
return [
5+
{
6+
name: "derived_config1",
7+
entry: "./src/index1.js",
8+
},
9+
{
10+
name: "derived_config2",
11+
entry: "./src/index2.js",
12+
},
13+
];
14+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2+
3+
module.exports = () => {
4+
console.log("base.webpack.config.js");
5+
6+
return {
7+
entry: "./src/index1.js",
8+
name: "base_config",
9+
mode: "development",
10+
plugins: [new WebpackCLITestPlugin()],
11+
12+
experiments: {
13+
topLevelAwait: true,
14+
},
15+
};
16+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("i am index1.js");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.log("i am index2.js");

0 commit comments

Comments
 (0)