Skip to content

Commit c6866ce

Browse files
committed
test: failing tests
1 parent 0f6d526 commit c6866ce

File tree

324 files changed

+9041
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

324 files changed

+9041
-1
lines changed

test/e2e-playwright/api-refactored.test.js

Lines changed: 718 additions & 0 deletions
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
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+
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+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[webp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"ws://test.host:8158/ws"
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+
[]
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+
["[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+
[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
["[HMR] Waiting for update signal from WDS...","[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading disabled, Progress disabled, Overlay disabled.","Hey."]

test/e2e-playwright/bonjour.test.js

Lines changed: 318 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,318 @@
1+
"use strict";
2+
3+
const os = require("os");
4+
const webpack = require("webpack");
5+
const { test } = require("@playwright/test");
6+
const { expect } = require("@playwright/test");
7+
const { describe } = require("@playwright/test");
8+
const { beforeEach, afterEach } = require("@playwright/test");
9+
// const { jest } = require("@jest/globals");
10+
const jestMock = require("jest-mock");
11+
const Server = require("../../lib/Server");
12+
const config = require("../fixtures/simple-config/webpack.config");
13+
const port = require("../ports-map").bonjour;
14+
15+
describe("bonjour option", () => {
16+
let mockPublish;
17+
let mockUnpublishAll;
18+
let mockDestroy;
19+
20+
beforeEach(() => {
21+
mockPublish = jestMock.fn();
22+
mockUnpublishAll = jestMock.fn((callback) => {
23+
callback();
24+
});
25+
mockDestroy = jestMock.fn();
26+
});
27+
28+
describe("as true", () => {
29+
let compiler;
30+
let server;
31+
let pageErrors;
32+
let consoleMessages;
33+
34+
beforeEach(async () => {
35+
jest.mock("bonjour-service", () => {
36+
return {
37+
Bonjour: jestMock.fn().mockImplementation(() => {
38+
return {
39+
publish: mockPublish,
40+
unpublishAll: mockUnpublishAll,
41+
destroy: mockDestroy,
42+
};
43+
}),
44+
};
45+
});
46+
47+
compiler = webpack(config);
48+
49+
server = new Server({ port, bonjour: true }, compiler);
50+
51+
await server.start();
52+
53+
pageErrors = [];
54+
consoleMessages = [];
55+
});
56+
57+
afterEach(async () => {
58+
await server.stop();
59+
60+
mockPublish.mockReset();
61+
mockUnpublishAll.mockReset();
62+
mockDestroy.mockReset();
63+
});
64+
65+
test("should call bonjour with correct params", async ({ page }) => {
66+
page
67+
.on("console", (message) => {
68+
consoleMessages.push(message);
69+
})
70+
.on("pageerror", (error) => {
71+
pageErrors.push(error);
72+
});
73+
74+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
75+
waitUntil: "networkidle0",
76+
});
77+
78+
expect(mockPublish).toHaveBeenCalledTimes(1);
79+
80+
expect(mockPublish).toHaveBeenCalledWith({
81+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
82+
port,
83+
type: "http",
84+
subtypes: ["webpack"],
85+
});
86+
87+
expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
88+
expect(mockDestroy).toHaveBeenCalledTimes(0);
89+
90+
expect(JSON.stringify(response.status())).toMatchSnapshot();
91+
92+
expect(JSON.stringify(consoleMessages.map((message) => message.text()))).toMatchSnapshot();
93+
94+
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
95+
});
96+
});
97+
98+
describe("with 'server' option", () => {
99+
let compiler;
100+
let server;
101+
let pageErrors;
102+
let consoleMessages;
103+
104+
beforeEach(async () => {
105+
jestMock.mock("bonjour-service", () => {
106+
return {
107+
Bonjour: jestMock.fn().mockImplementation(() => {
108+
return {
109+
publish: mockPublish,
110+
unpublishAll: mockUnpublishAll,
111+
destroy: mockDestroy,
112+
};
113+
}),
114+
};
115+
});
116+
117+
compiler = webpack(config);
118+
119+
server = new Server({ bonjour: true, port, server: "https" }, compiler);
120+
121+
await server.start();
122+
123+
pageErrors = [];
124+
consoleMessages = [];
125+
});
126+
127+
afterEach(async () => {
128+
await server.stop();
129+
});
130+
131+
test("should call bonjour with 'https' type", async ({ page }) => {
132+
page
133+
.on("console", (message) => {
134+
consoleMessages.push(message);
135+
})
136+
.on("pageerror", (error) => {
137+
pageErrors.push(error);
138+
});
139+
140+
const response = await page.goto(`https://127.0.0.1:${port}/`, {
141+
waitUntil: "networkidle0",
142+
});
143+
144+
expect(mockPublish).toHaveBeenCalledTimes(1);
145+
146+
expect(mockPublish).toHaveBeenCalledWith({
147+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
148+
port,
149+
type: "https",
150+
subtypes: ["webpack"],
151+
});
152+
153+
expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
154+
expect(mockDestroy).toHaveBeenCalledTimes(0);
155+
156+
expect(JSON.stringify(response.status())).toMatchSnapshot();
157+
158+
expect(JSON.stringify(consoleMessages.map((message) => message.text()))).toMatchSnapshot();
159+
160+
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
161+
});
162+
});
163+
164+
describe("as object", () => {
165+
let compiler;
166+
let server;
167+
let pageErrors;
168+
let consoleMessages;
169+
170+
beforeEach(async () => {
171+
jest.mock("bonjour-service", () => {
172+
return {
173+
Bonjour: jestMock.fn().mockImplementation(() => {
174+
return {
175+
publish: mockPublish,
176+
unpublishAll: mockUnpublishAll,
177+
destroy: mockDestroy,
178+
};
179+
}),
180+
};
181+
});
182+
183+
compiler = webpack(config);
184+
185+
server = new Server(
186+
{
187+
port,
188+
bonjour: {
189+
type: "https",
190+
protocol: "udp",
191+
},
192+
},
193+
compiler,
194+
);
195+
196+
await server.start();
197+
198+
pageErrors = [];
199+
consoleMessages = [];
200+
});
201+
202+
afterEach(async () => {
203+
await server.stop();
204+
});
205+
206+
test("should apply bonjour options", async ({ page }) => {
207+
page
208+
.on("console", (message) => {
209+
consoleMessages.push(message);
210+
})
211+
.on("pageerror", (error) => {
212+
pageErrors.push(error);
213+
});
214+
215+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
216+
waitUntil: "networkidle0",
217+
});
218+
219+
expect(mockPublish).toHaveBeenCalledTimes(1);
220+
221+
expect(mockPublish).toHaveBeenCalledWith({
222+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
223+
port,
224+
type: "https",
225+
protocol: "udp",
226+
subtypes: ["webpack"],
227+
});
228+
229+
expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
230+
expect(mockDestroy).toHaveBeenCalledTimes(0);
231+
232+
expect(JSON.stringify(response.status())).toMatchSnapshot();
233+
234+
expect(JSON.stringify(consoleMessages.map((message) => message.text()))).toMatchSnapshot();
235+
236+
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
237+
});
238+
});
239+
240+
describe("bonjour object and 'server' option", () => {
241+
let compiler;
242+
let server;
243+
let pageErrors;
244+
let consoleMessages;
245+
246+
beforeEach(async () => {
247+
jest.mock("bonjour-service", () => {
248+
return {
249+
Bonjour: jestMock.fn().mockImplementation(() => {
250+
return {
251+
publish: mockPublish,
252+
unpublishAll: mockUnpublishAll,
253+
destroy: mockDestroy,
254+
};
255+
}),
256+
};
257+
});
258+
259+
compiler = webpack(config);
260+
261+
server = new Server(
262+
{
263+
port,
264+
bonjour: {
265+
type: "http",
266+
protocol: "udp",
267+
},
268+
server: {
269+
type: "https",
270+
},
271+
},
272+
compiler,
273+
);
274+
275+
await server.start();
276+
277+
pageErrors = [];
278+
consoleMessages = [];
279+
});
280+
281+
afterEach(async () => {
282+
await server.stop();
283+
});
284+
285+
test("should apply bonjour options", async ({ page }) => {
286+
page
287+
.on("console", (message) => {
288+
consoleMessages.push(message);
289+
})
290+
.on("pageerror", (error) => {
291+
pageErrors.push(error);
292+
});
293+
294+
const response = await page.goto(`https://127.0.0.1:${port}/`, {
295+
waitUntil: "networkidle0",
296+
});
297+
298+
expect(mockPublish).toHaveBeenCalledTimes(1);
299+
300+
expect(mockPublish).toHaveBeenCalledWith({
301+
name: `Webpack Dev Server ${os.hostname()}:${port}`,
302+
port,
303+
type: "http",
304+
protocol: "udp",
305+
subtypes: ["webpack"],
306+
});
307+
308+
expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
309+
expect(mockDestroy).toHaveBeenCalledTimes(0);
310+
311+
expect(JSON.stringify(response.status())).toMatchSnapshot();
312+
313+
expect(JSON.stringify(consoleMessages.map((message) => message.text()))).toMatchSnapshot();
314+
315+
expect(JSON.stringify(pageErrors)).toMatchSnapshot();
316+
});
317+
});
318+
});

0 commit comments

Comments
 (0)