Skip to content

Commit 5e6a387

Browse files
test: rerun dev server (#3824)
1 parent 011bcf1 commit 5e6a387

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

test/e2e/__snapshots__/api.test.js.snap.webpack4

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

3+
exports[`API should work and allow to rerun dev server multiple times: 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[`API should work and allow to rerun dev server multiple times: console messages 2`] = `
13+
Array [
14+
"[HMR] Waiting for update signal from WDS...",
15+
"Hey.",
16+
"[webpack-dev-server] Hot Module Replacement enabled.",
17+
"[webpack-dev-server] Live Reloading enabled.",
18+
]
19+
`;
20+
21+
exports[`API should work and allow to rerun dev server multiple times: page errors 1`] = `Array []`;
22+
23+
exports[`API should work and allow to rerun dev server multiple times: page errors 2`] = `Array []`;
24+
325
exports[`API should work when using configured manually: console messages 1`] = `
426
Array [
527
"[HMR] Waiting for update signal from WDS...",

test/e2e/__snapshots__/api.test.js.snap.webpack5

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

3+
exports[`API should work and allow to rerun dev server multiple times: 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[`API should work and allow to rerun dev server multiple times: console messages 2`] = `
13+
Array [
14+
"[HMR] Waiting for update signal from WDS...",
15+
"Hey.",
16+
"[webpack-dev-server] Hot Module Replacement enabled.",
17+
"[webpack-dev-server] Live Reloading enabled.",
18+
]
19+
`;
20+
21+
exports[`API should work and allow to rerun dev server multiple times: page errors 1`] = `Array []`;
22+
23+
exports[`API should work and allow to rerun dev server multiple times: page errors 2`] = `Array []`;
24+
325
exports[`API should work when using configured manually: console messages 1`] = `
426
Array [
527
"[HMR] Waiting for update signal from WDS...",

test/e2e/api.test.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,63 @@ describe("API", () => {
123123
await server.stop();
124124
});
125125

126+
it(`should work and allow to rerun dev server multiple times`, async () => {
127+
const compiler = webpack(config);
128+
const server = new Server({ port }, compiler);
129+
130+
await server.start();
131+
132+
const { page: firstPage, browser } = await runBrowser();
133+
134+
const firstPageErrors = [];
135+
const firstConsoleMessages = [];
136+
137+
firstPage
138+
.on("console", (message) => {
139+
firstConsoleMessages.push(message);
140+
})
141+
.on("pageerror", (error) => {
142+
firstPageErrors.push(error);
143+
});
144+
145+
await firstPage.goto(`http://127.0.0.1:${port}/main`, {
146+
waitUntil: "networkidle0",
147+
});
148+
149+
expect(
150+
firstConsoleMessages.map((message) => message.text())
151+
).toMatchSnapshot("console messages");
152+
expect(firstPageErrors).toMatchSnapshot("page errors");
153+
154+
await server.stop();
155+
await server.start();
156+
157+
const secondPage = await browser.newPage();
158+
159+
const secondPageErrors = [];
160+
const secondConsoleMessages = [];
161+
162+
secondPage
163+
.on("console", (message) => {
164+
secondConsoleMessages.push(message);
165+
})
166+
.on("pageerror", (error) => {
167+
secondPageErrors.push(error);
168+
});
169+
170+
await secondPage.goto(`http://127.0.0.1:${port}/main`, {
171+
waitUntil: "networkidle0",
172+
});
173+
174+
expect(
175+
secondConsoleMessages.map((message) => message.text())
176+
).toMatchSnapshot("console messages");
177+
expect(secondPageErrors).toMatchSnapshot("page errors");
178+
179+
await browser.close();
180+
await server.stop();
181+
});
182+
126183
it("should work with deprecated API ('listen' and `close` methods)", async () => {
127184
const compiler = webpack(config);
128185
const devServerOptions = { port };

0 commit comments

Comments
 (0)