Skip to content

Commit ab7cf84

Browse files
committed
feat: update bonjour.test.js
1 parent c3f7b16 commit ab7cf84

File tree

17 files changed

+81
-59
lines changed

17 files changed

+81
-59
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
200

test/e2e/bonjour.test.js

Lines changed: 65 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,46 @@
22

33
const os = require("os");
44
const webpack = require("webpack");
5-
const { describe, test, beforeEach, beforeAll, afterEach } = require("@playwright/test");
65
const sinon = require("sinon");
76
const bonjourService = require("bonjour-service");
7+
const { test } = require("../helpers/playwright-test");
88
const { expect } = require("../helpers/playwright-custom-expects");
99
const Server = require("../../lib/Server");
1010
const config = require("../fixtures/simple-config/webpack.config");
1111
const port = require("../ports-map").bonjour;
1212

13-
describe("bonjour option", { tag: "@flaky" }, () => {
13+
test.describe("bonjour option", { tag: "@flaky" }, () => {
1414
let mockPublish;
1515
let mockUnpublishAll;
1616
let mockDestroy;
1717

18-
beforeAll(() => {
18+
test.beforeAll(() => {
1919
mockPublish = sinon.stub();
2020
mockUnpublishAll = sinon.stub().callsFake((callback) => {
2121
callback();
2222
});
2323
mockDestroy = sinon.stub();
2424

25-
sinon.stub(bonjourService, 'Bonjour').returns({
25+
sinon.stub(bonjourService, "Bonjour").returns({
2626
publish: mockPublish,
2727
unpublishAll: mockUnpublishAll,
2828
destroy: mockDestroy,
29-
})
29+
});
3030
});
3131

32-
afterEach(() => {
32+
test.afterEach(() => {
3333
mockPublish.resetHistory();
3434
mockUnpublishAll.resetHistory();
3535
mockDestroy.resetHistory();
36-
})
36+
});
3737

38-
describe("as true", () => {
38+
test.describe("as true", () => {
3939
let compiler;
4040
let server;
4141
let pageErrors;
4242
let consoleMessages;
4343

44-
beforeEach(async () => {
44+
test.beforeEach(async () => {
4545
compiler = webpack(config);
4646

4747
server = new Server({ port, bonjour: true }, compiler);
@@ -52,7 +52,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
5252
consoleMessages = [];
5353
});
5454

55-
afterEach(async () => {
55+
test.afterEach(async () => {
5656
await server.stop();
5757
});
5858

@@ -71,35 +71,35 @@ describe("bonjour option", { tag: "@flaky" }, () => {
7171

7272
expect(mockPublish.callCount).toBe(1);
7373

74-
expect(mockPublish.calledWith(
75-
{
74+
expect(
75+
mockPublish.calledWith({
7676
name: `Webpack Dev Server ${os.hostname()}:${port}`,
7777
port,
7878
type: "http",
7979
subtypes: ["webpack"],
80-
}
81-
)).toBeTruthy();
80+
}),
81+
).toBeTruthy();
8282

8383
expect(mockUnpublishAll.callCount).toBe(0);
8484
expect(mockDestroy.callCount).toBe(0);
8585

86-
expect(response.status()).toMatchSnapshotWithArray();
86+
expect(response.status()).toMatchSnapshotWithArray("response status");
8787

8888
expect(
89-
consoleMessages.map((message) => message.text()))
90-
.toMatchSnapshotWithArray();
89+
consoleMessages.map((message) => message.text()),
90+
).toMatchSnapshotWithArray("console messages");
9191

92-
expect(pageErrors).toMatchSnapshotWithArray();
92+
expect(pageErrors).toMatchSnapshotWithArray("page errors");
9393
});
9494
});
9595

96-
describe("with 'server' option", () => {
96+
test.describe("with 'server' option", () => {
9797
let compiler;
9898
let server;
9999
let pageErrors;
100100
let consoleMessages;
101101

102-
beforeEach(async () => {
102+
test.beforeEach(async () => {
103103
compiler = webpack(config);
104104

105105
server = new Server({ bonjour: true, port, server: "https" }, compiler);
@@ -110,7 +110,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
110110
consoleMessages = [];
111111
});
112112

113-
afterEach(async () => {
113+
test.afterEach(async () => {
114114
await server.stop();
115115
});
116116

@@ -129,33 +129,35 @@ describe("bonjour option", { tag: "@flaky" }, () => {
129129

130130
expect(mockPublish.callCount).toBe(1);
131131

132-
expect(mockPublish.calledWith({
133-
name: `Webpack Dev Server ${os.hostname()}:${port}`,
134-
port,
135-
type: "https",
136-
subtypes: ["webpack"],
137-
})).toBeTruthy();
132+
expect(
133+
mockPublish.calledWith({
134+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
135+
port,
136+
type: "https",
137+
subtypes: ["webpack"],
138+
}),
139+
).toBeTruthy();
138140

139141
expect(mockUnpublishAll.callCount).toBe(0);
140142
expect(mockDestroy.callCount).toBe(0);
141143

142-
expect(response.status()).toMatchSnapshotWithArray();
144+
expect(response.status()).toMatchSnapshotWithArray("response status");
143145

144146
expect(
145-
consoleMessages.map((message) => message.text()))
146-
.toMatchSnapshotWithArray();
147+
consoleMessages.map((message) => message.text()),
148+
).toMatchSnapshotWithArray("console messages");
147149

148-
expect(pageErrors).toMatchSnapshotWithArray();
150+
expect(pageErrors).toMatchSnapshotWithArray("page errors");
149151
});
150152
});
151153

152-
describe("as object", () => {
154+
test.describe("as object", () => {
153155
let compiler;
154156
let server;
155157
let pageErrors;
156158
let consoleMessages;
157159

158-
beforeEach(async () => {
160+
test.beforeEach(async () => {
159161
compiler = webpack(config);
160162

161163
server = new Server(
@@ -175,7 +177,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
175177
consoleMessages = [];
176178
});
177179

178-
afterEach(async () => {
180+
test.afterEach(async () => {
179181
await server.stop();
180182
});
181183

@@ -194,34 +196,36 @@ describe("bonjour option", { tag: "@flaky" }, () => {
194196

195197
expect(mockPublish.callCount).toBe(1);
196198

197-
expect(mockPublish.calledWith({
198-
name: `Webpack Dev Server ${os.hostname()}:${port}`,
199-
port,
200-
type: "https",
201-
protocol: "udp",
202-
subtypes: ["webpack"],
203-
})).toBeTruthy();
199+
expect(
200+
mockPublish.calledWith({
201+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
202+
port,
203+
type: "https",
204+
protocol: "udp",
205+
subtypes: ["webpack"],
206+
}),
207+
).toBeTruthy();
204208

205209
expect(mockUnpublishAll.callCount).toBe(0);
206210
expect(mockDestroy.callCount).toBe(0);
207211

208-
expect(response.status()).toMatchSnapshotWithArray();
212+
expect(response.status()).toMatchSnapshotWithArray("response status");
209213

210214
expect(
211-
consoleMessages.map((message) => message.text()))
212-
.toMatchSnapshotWithArray();
215+
consoleMessages.map((message) => message.text()),
216+
).toMatchSnapshotWithArray("console messages");
213217

214-
expect(pageErrors).toMatchSnapshotWithArray();
218+
expect(pageErrors).toMatchSnapshotWithArray("page errors");
215219
});
216220
});
217221

218-
describe("bonjour object and 'server' option", () => {
222+
test.describe("bonjour object and 'server' option", () => {
219223
let compiler;
220224
let server;
221225
let pageErrors;
222226
let consoleMessages;
223227

224-
beforeEach(async () => {
228+
test.beforeEach(async () => {
225229
compiler = webpack(config);
226230

227231
server = new Server(
@@ -244,7 +248,7 @@ describe("bonjour option", { tag: "@flaky" }, () => {
244248
consoleMessages = [];
245249
});
246250

247-
afterEach(async () => {
251+
test.afterEach(async () => {
248252
await server.stop();
249253
});
250254

@@ -263,24 +267,26 @@ describe("bonjour option", { tag: "@flaky" }, () => {
263267

264268
expect(mockPublish.callCount).toBe(1);
265269

266-
expect(mockPublish.calledWith({
267-
name: `Webpack Dev Server ${os.hostname()}:${port}`,
268-
port,
269-
type: "http",
270-
protocol: "udp",
271-
subtypes: ["webpack"],
272-
})).toBeTruthy();
270+
expect(
271+
mockPublish.calledWith({
272+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
273+
port,
274+
type: "http",
275+
protocol: "udp",
276+
subtypes: ["webpack"],
277+
}),
278+
).toBeTruthy();
273279

274280
expect(mockUnpublishAll.callCount).toBe(0);
275281
expect(mockDestroy.callCount).toBe(0);
276282

277-
expect(response.status()).toMatchSnapshotWithArray();
283+
expect(response.status()).toMatchSnapshotWithArray("response status");
278284

279285
expect(
280-
consoleMessages.map((message) => message.text()))
281-
.toMatchSnapshotWithArray();
286+
consoleMessages.map((message) => message.text()),
287+
).toMatchSnapshotWithArray("console messages");
282288

283-
expect(pageErrors).toMatchSnapshotWithArray();
289+
expect(pageErrors).toMatchSnapshotWithArray("page errors");
284290
});
285291
});
286292
});

0 commit comments

Comments
 (0)