Skip to content

Commit 6d650b1

Browse files
committed
fixup!
1 parent 7fd754d commit 6d650b1

2 files changed

Lines changed: 39 additions & 38 deletions

File tree

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
1-
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2-
3-
exports[`API (plugin) MultiCompiler should work with plugin API: console messages 1`] = `
1+
exports[`API (plugin) > MultiCompiler > should work with plugin API 1`] = `
42
[
53
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
64
"[HMR] Waiting for update signal from WDS...",
75
"one",
86
]
97
`;
108

11-
exports[`API (plugin) MultiCompiler should work with plugin API: page errors 1`] = `[]`;
9+
exports[`API (plugin) > MultiCompiler > should work with plugin API 2`] = `
10+
[]
11+
`;
1212

13-
exports[`API (plugin) plugin in webpack config should work when added to webpack config plugins array: console messages 1`] = `
13+
exports[`API (plugin) > plugin in webpack config > should work when added to webpack config plugins array 1`] = `
1414
[
1515
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
1616
"[HMR] Waiting for update signal from WDS...",
1717
"Hey.",
1818
]
1919
`;
2020

21-
exports[`API (plugin) plugin in webpack config should work when added to webpack config plugins array: page errors 1`] = `[]`;
21+
exports[`API (plugin) > plugin in webpack config > should work when added to webpack config plugins array 2`] = `
22+
[]
23+
`;
2224

23-
exports[`API (plugin) plugin in webpack config should work with output.clean: true: console messages 1`] = `
25+
exports[`API (plugin) > plugin in webpack config > should work with output.clean: true 1`] = `
2426
[
2527
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
2628
"[HMR] Waiting for update signal from WDS...",
2729
"Hey.",
2830
]
2931
`;
3032

31-
exports[`API (plugin) plugin in webpack config should work with output.clean: true: page errors 1`] = `[]`;
33+
exports[`API (plugin) > plugin in webpack config > should work with output.clean: true 2`] = `
34+
[]
35+
`;
3236

33-
exports[`API (plugin) should work with plugin API: console messages 1`] = `
37+
exports[`API (plugin) > should work with plugin API 1`] = `
3438
[
3539
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
3640
"[HMR] Waiting for update signal from WDS...",
3741
"Hey.",
3842
]
3943
`;
4044

41-
exports[`API (plugin) should work with plugin API: page errors 1`] = `[]`;
45+
exports[`API (plugin) > should work with plugin API 2`] = `
46+
[]
47+
`;

test/e2e/api-plugin.test.js

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
const os = require("node:os");
44
const path = require("node:path");
5+
const { describe, it } = require("node:test");
6+
const { expect } = require("expect");
7+
const { spyOn } = require("jest-mock");
58
const webpack = require("webpack");
69
const WebSocket = require("ws");
710
const Server = require("../../lib/Server");
@@ -13,7 +16,7 @@ const port = require("../ports-map")["api-plugin"];
1316
const [portA, portB] = require("../ports-map")["api-plugin-multi"];
1417

1518
describe("API (plugin)", () => {
16-
it("should work with plugin API", async () => {
19+
it("should work with plugin API", async (t) => {
1720
const compiler = webpack(config);
1821
const server = new Server({ port });
1922

@@ -38,10 +41,8 @@ describe("API (plugin)", () => {
3841
waitUntil: "networkidle0",
3942
});
4043

41-
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
42-
"console messages",
43-
);
44-
expect(pageErrors).toMatchSnapshot("page errors");
44+
t.assert.snapshot(consoleMessages.map((message) => message.text()));
45+
t.assert.snapshot(pageErrors);
4546

4647
await browser.close();
4748
await new Promise((resolve) => {
@@ -52,8 +53,8 @@ describe("API (plugin)", () => {
5253
it("should not start the server multiple times on recompilation", async () => {
5354
const compiler = webpack(config);
5455
const server = new Server({ port });
55-
const setupSpy = jest.spyOn(server, "setup");
56-
const listenSpy = jest.spyOn(server, "listen");
56+
const setupSpy = spyOn(server, "setup");
57+
const listenSpy = spyOn(server, "listen");
5758

5859
server.apply(compiler);
5960

@@ -84,7 +85,7 @@ describe("API (plugin)", () => {
8485
it("should stop the server cleanly via compiler.close()", async () => {
8586
const compiler = webpack(config);
8687
const server = new Server({ port });
87-
const stopSpy = jest.spyOn(server, "stop");
88+
const stopSpy = spyOn(server, "stop");
8889

8990
server.apply(compiler);
9091

@@ -110,8 +111,8 @@ describe("API (plugin)", () => {
110111
},
111112
});
112113
const server = new Server({ port });
113-
const setupSpy = jest.spyOn(server, "setup");
114-
const listenSpy = jest.spyOn(server, "listen");
114+
const setupSpy = spyOn(server, "setup");
115+
const listenSpy = spyOn(server, "listen");
115116

116117
server.apply(compiler);
117118

@@ -239,7 +240,7 @@ describe("API (plugin)", () => {
239240
});
240241

241242
describe("plugin in webpack config", () => {
242-
it("should work when added to webpack config plugins array", async () => {
243+
it("should work when added to webpack config plugins array", async (t) => {
243244
const server = new Server({ port });
244245
const compiler = webpack({
245246
...config,
@@ -266,10 +267,8 @@ describe("API (plugin)", () => {
266267
waitUntil: "networkidle0",
267268
});
268269

269-
expect(
270-
consoleMessages.map((message) => message.text()),
271-
).toMatchSnapshot("console messages");
272-
expect(pageErrors).toMatchSnapshot("page errors");
270+
t.assert.snapshot(consoleMessages.map((message) => message.text()));
271+
t.assert.snapshot(pageErrors);
273272
} finally {
274273
await browser.close();
275274
await new Promise((resolve) => {
@@ -278,7 +277,7 @@ describe("API (plugin)", () => {
278277
}
279278
});
280279

281-
it("should work with output.clean: true", async () => {
280+
it("should work with output.clean: true", async (t) => {
282281
const server = new Server({ port });
283282
const compiler = webpack({
284283
...config,
@@ -310,10 +309,8 @@ describe("API (plugin)", () => {
310309
});
311310

312311
expect(response.status()).toBe(200);
313-
expect(
314-
consoleMessages.map((message) => message.text()),
315-
).toMatchSnapshot("console messages");
316-
expect(pageErrors).toMatchSnapshot("page errors");
312+
t.assert.snapshot(consoleMessages.map((message) => message.text()));
313+
t.assert.snapshot(pageErrors);
317314
} finally {
318315
await browser.close();
319316
await new Promise((resolve) => {
@@ -324,7 +321,7 @@ describe("API (plugin)", () => {
324321
});
325322

326323
describe("MultiCompiler", () => {
327-
it("should work with plugin API", async () => {
324+
it("should work with plugin API", async (t) => {
328325
const compiler = webpack(multiCompilerConfig);
329326
const server = new Server({ port });
330327

@@ -354,10 +351,8 @@ describe("API (plugin)", () => {
354351
);
355352

356353
expect(response.status()).toBe(200);
357-
expect(
358-
consoleMessages.map((message) => message.text()),
359-
).toMatchSnapshot("console messages");
360-
expect(pageErrors).toMatchSnapshot("page errors");
354+
t.assert.snapshot(consoleMessages.map((message) => message.text()));
355+
t.assert.snapshot(pageErrors);
361356
} finally {
362357
await browser.close();
363358
await new Promise((resolve) => {
@@ -369,8 +364,8 @@ describe("API (plugin)", () => {
369364
it("should call setup and listen once across all child compilers", async () => {
370365
const compiler = webpack(multiCompilerConfig);
371366
const server = new Server({ port });
372-
const setupSpy = jest.spyOn(server, "setup");
373-
const listenSpy = jest.spyOn(server, "listen");
367+
const setupSpy = spyOn(server, "setup");
368+
const listenSpy = spyOn(server, "listen");
374369

375370
server.apply(compiler);
376371

@@ -389,7 +384,7 @@ describe("API (plugin)", () => {
389384
it("should stop the server only once when all child compilers shut down", async () => {
390385
const compiler = webpack(multiCompilerConfig);
391386
const server = new Server({ port });
392-
const stopSpy = jest.spyOn(server, "stop");
387+
const stopSpy = spyOn(server, "stop");
393388

394389
server.apply(compiler);
395390

0 commit comments

Comments
 (0)