Skip to content

Commit c3cd6b7

Browse files
committed
test: add e2e test for plugin API
1 parent cf33c23 commit c3cd6b7

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,14 @@ Array [
8787
`;
8888

8989
exports[`API should work with deprecated API (the order of the arguments in the constructor): page errors 1`] = `Array []`;
90+
91+
exports[`API should work with plugin API: console messages 1`] = `
92+
Array [
93+
"[HMR] Waiting for update signal from WDS...",
94+
"Hey.",
95+
"[webpack-dev-server] Hot Module Replacement enabled.",
96+
"[webpack-dev-server] Live Reloading enabled.",
97+
]
98+
`;
99+
100+
exports[`API should work with plugin API: page errors 1`] = `Array []`;

test/e2e/api.test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,38 @@ const runBrowser = require("../helpers/run-browser");
88
const port = require("../ports-map").api;
99

1010
describe("API", () => {
11+
it(`should work with plugin API`, async () => {
12+
const compiler = webpack(config);
13+
const server = new Server({ port });
14+
15+
server.apply(compiler);
16+
17+
const { page, browser } = await runBrowser();
18+
19+
const pageErrors = [];
20+
const consoleMessages = [];
21+
22+
page
23+
.on("console", (message) => {
24+
consoleMessages.push(message);
25+
})
26+
.on("pageerror", (error) => {
27+
pageErrors.push(error);
28+
});
29+
30+
await page.goto(`http://127.0.0.1:${port}/main`, {
31+
waitUntil: "networkidle0",
32+
});
33+
34+
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
35+
"console messages"
36+
);
37+
expect(pageErrors).toMatchSnapshot("page errors");
38+
39+
await browser.close();
40+
await server.stop();
41+
});
42+
1143
it(`should work with async API`, async () => {
1244
const compiler = webpack(config);
1345
const server = new Server({ port }, compiler);

0 commit comments

Comments
 (0)