Skip to content

Commit 4cd9245

Browse files
committed
test: add e2e tests for multi compiler mode
1 parent 1307332 commit 4cd9245

File tree

6 files changed

+106
-49
lines changed

6 files changed

+106
-49
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Multi compiler should work with multiple compilers: console messages 1`] = `
4+
Array [
5+
"[HMR] Waiting for update signal from WDS...",
6+
"Hey.",
7+
"[webpack-dev-server] Hot Module Replacement enabled.",
8+
"[webpack-dev-server] Live Reloading enabled.",
9+
]
10+
`;
11+
12+
exports[`Multi compiler should work with multiple compilers: page errors 1`] = `Array []`;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Multi compiler should work with multiple compilers: console messages 1`] = `
4+
Array [
5+
"[HMR] Waiting for update signal from WDS...",
6+
"Hey.",
7+
"[webpack-dev-server] Hot Module Replacement enabled.",
8+
"[webpack-dev-server] Live Reloading enabled.",
9+
]
10+
`;
11+
12+
exports[`Multi compiler should work with multiple compilers: page errors 1`] = `Array []`;

test/e2e/multi-compiler.test.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
"use strict";
2+
3+
const webpack = require("webpack");
4+
const Server = require("../../lib/Server");
5+
const config = require("../fixtures/multi-compiler-config/webpack.config");
6+
const runBrowser = require("../helpers/run-browser");
7+
const port = require("../ports-map")["multi-compiler"];
8+
9+
describe("Multi compiler", () => {
10+
it(`should work with multiple compilers`, async () => {
11+
const compiler = webpack(config);
12+
const devServerOptions = {
13+
host: "127.0.0.1",
14+
port,
15+
};
16+
const server = new Server(devServerOptions, compiler);
17+
18+
await new Promise((resolve, reject) => {
19+
server.listen(port, "127.0.0.1", (error) => {
20+
if (error) {
21+
reject(error);
22+
23+
return;
24+
}
25+
26+
resolve();
27+
});
28+
});
29+
30+
const { page, browser } = await runBrowser();
31+
32+
const pageErrors = [];
33+
const consoleMessages = [];
34+
35+
page
36+
.on("console", (message) => {
37+
consoleMessages.push(message);
38+
})
39+
.on("pageerror", (error) => {
40+
pageErrors.push(error);
41+
});
42+
43+
await page.goto(`http://127.0.0.1:${port}/main`, {
44+
waitUntil: "networkidle0",
45+
});
46+
47+
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
48+
"console messages"
49+
);
50+
51+
expect(pageErrors).toMatchSnapshot("page errors");
52+
53+
await browser.close();
54+
await new Promise((resolve, reject) => {
55+
server.close((error) => {
56+
if (error) {
57+
reject(error);
58+
59+
return;
60+
}
61+
62+
resolve();
63+
});
64+
});
65+
});
66+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
console.log("bar");

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,17 @@ module.exports = [
1414
level: "warn",
1515
},
1616
},
17+
{
18+
mode: "development",
19+
context: __dirname,
20+
stats: "none",
21+
entry: "./bar.js",
22+
output: {
23+
path: "/",
24+
},
25+
node: false,
26+
infrastructureLogging: {
27+
level: "warn",
28+
},
29+
},
1730
];

test/integration/MultiCompiler.test.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)