Skip to content

Commit feedeab

Browse files
test: add
1 parent 65a8fda commit feedeab

File tree

5 files changed

+58
-15
lines changed

5 files changed

+58
-15
lines changed

test/cli/__snapshots__/basic.test.js.snap.webpack4

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`basic basic should accept the promise function of webpack.config.js: stderr 1`] = `
4+
"<i> [webpack-dev-server] Project is running at:
5+
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
6+
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
7+
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
9+
`;
10+
311
exports[`basic basic should work using "--host localhost --port <port>": stderr 1`] = `
412
"<i> [webpack-dev-server] Project is running at:
513
<i> [webpack-dev-server] Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/
614
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
715
`;
816

17+
exports[`basic basic should work using multi compiler mode: stderr 1`] = `
18+
"<i> [webpack-dev-server] Project is running at:
19+
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
20+
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
21+
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
22+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
23+
`;
24+
925
exports[`basic basic should work: stderr 1`] = `
1026
"<i> [webpack-dev-server] Project is running at:
1127
<i> [webpack-dev-server] Loopback: http://localhost:<port>/

test/cli/__snapshots__/basic.test.js.snap.webpack5

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`basic basic should accept the promise function of webpack.config.js: stderr 1`] = `
4+
"<i> [webpack-dev-server] Project is running at:
5+
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
6+
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
7+
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
8+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
9+
`;
10+
311
exports[`basic basic should work using "--host localhost --port <port>": stderr 1`] = `
412
"<i> [webpack-dev-server] Project is running at:
513
<i> [webpack-dev-server] Loopback: http://localhost:<port>/, http://<ip-v4>:<port>/
614
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
715
`;
816

17+
exports[`basic basic should work using multi compiler mode: stderr 1`] = `
18+
"<i> [webpack-dev-server] Project is running at:
19+
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
20+
<i> [webpack-dev-server] On Your Network (IPv4): http://<ip-v4>:<port>/
21+
<i> [webpack-dev-server] On Your Network (IPv6): http://[<ip-v6>]:<port>/
22+
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/public' directory"
23+
`;
24+
925
exports[`basic basic should work: stderr 1`] = `
1026
"<i> [webpack-dev-server] Project is running at:
1127
<i> [webpack-dev-server] Loopback: http://localhost:<port>/

test/cli/basic.test.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe("basic", () => {
6767

6868
it("should accept the promise function of webpack.config.js", async () => {
6969
try {
70-
const { exitCode } = await testBin([
70+
await testBin([
7171
"--config",
7272
path.resolve(
7373
__dirname,
@@ -76,10 +76,29 @@ describe("basic", () => {
7676
"--port",
7777
port,
7878
]);
79-
expect(exitCode).toEqual(0);
80-
} catch (err) {
81-
// for windows
82-
expect(err.stdout).toContain("main.js");
79+
} catch (error) {
80+
expect(error.stdout).toContain("main.js");
81+
expect(normalizeStderr(error.stderr, { ipv6: true })).toMatchSnapshot(
82+
"stderr"
83+
);
84+
}
85+
});
86+
87+
it("should work using multi compiler mode", async () => {
88+
try {
89+
await testBin([
90+
"--config",
91+
path.resolve(
92+
__dirname,
93+
"../fixtures/universal-compiler-config/webpack.config.js"
94+
),
95+
"--port",
96+
port,
97+
]);
98+
} catch (error) {
99+
expect(normalizeStderr(error.stderr, { ipv6: true })).toMatchSnapshot(
100+
"stderr"
101+
);
83102
}
84103
});
85104

test/fixtures/universal-compiler-config/webpack.config.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ module.exports = [
1010
path: "/",
1111
filename: "client.js",
1212
},
13-
node: false,
14-
infrastructureLogging: {
15-
level: "warn",
16-
},
1713
},
1814
{
1915
mode: "development",
@@ -25,9 +21,5 @@ module.exports = [
2521
path: "/",
2622
filename: "server.js",
2723
},
28-
node: false,
29-
infrastructureLogging: {
30-
level: "warn",
31-
},
3224
},
3325
];

test/helpers/test-bin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const basicConfigPath = path.resolve(
1414
"../fixtures/cli/webpack.config.js"
1515
);
1616

17-
const testBin = (testArgs = []) => {
17+
const testBin = (testArgs = [], options) => {
1818
const cwd = process.cwd();
1919
const env = {
2020
WEBPACK_CLI_HELP_WIDTH: 2048,
@@ -37,7 +37,7 @@ const testBin = (testArgs = []) => {
3737
args = [webpackDevServerPath, ...configOptions, ...testArgs];
3838
}
3939

40-
return execa("node", args, { cwd, env, timeout: 10000 });
40+
return execa("node", args, { cwd, env, timeout: 5000, ...options });
4141
};
4242

4343
const ipV4 =

0 commit comments

Comments
 (0)