Skip to content

Commit 2573bf2

Browse files
committed
fixup!
1 parent 1cd55ba commit 2573bf2

2 files changed

Lines changed: 0 additions & 201 deletions

File tree

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

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -213,39 +213,3 @@ exports[`API > latest async API > should work with callback API 1`] = `
213213
exports[`API > latest async API > should work with callback API 2`] = `
214214
[]
215215
`;
216-
217-
exports[`API > plugin in webpack config > should work when added to webpack config plugins array 1`] = `
218-
[
219-
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
220-
"[HMR] Waiting for update signal from WDS...",
221-
"Hey.",
222-
]
223-
`;
224-
225-
exports[`API > plugin in webpack config > should work when added to webpack config plugins array 2`] = `
226-
[]
227-
`;
228-
229-
exports[`API > plugin in webpack config > should work with output.clean: true 1`] = `
230-
[
231-
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
232-
"[HMR] Waiting for update signal from WDS...",
233-
"Hey.",
234-
]
235-
`;
236-
237-
exports[`API > plugin in webpack config > should work with output.clean: true 2`] = `
238-
[]
239-
`;
240-
241-
exports[`API > should work with plugin API 1`] = `
242-
[
243-
"[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.",
244-
"[HMR] Waiting for update signal from WDS...",
245-
"Hey.",
246-
]
247-
`;
248-
249-
exports[`API > should work with plugin API 2`] = `
250-
[]
251-
`;

test/e2e/api.test.js

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -14,171 +14,6 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1414
const port = portsMap.api;
1515

1616
describe("API", () => {
17-
it("should work with plugin API", async (t) => {
18-
const compiler = webpack(config);
19-
const server = new Server({ port });
20-
21-
server.apply(compiler);
22-
23-
await compile(compiler, port);
24-
25-
const { page, browser } = await runBrowser();
26-
27-
const pageErrors = [];
28-
const consoleMessages = [];
29-
30-
page
31-
.on("console", (message) => {
32-
consoleMessages.push(message);
33-
})
34-
.on("pageerror", (error) => {
35-
pageErrors.push(error);
36-
});
37-
38-
await page.goto(`http://127.0.0.1:${port}/`, {
39-
waitUntil: "networkidle0",
40-
});
41-
42-
t.assert.snapshot(consoleMessages.map((message) => message.text()));
43-
44-
t.assert.snapshot(pageErrors);
45-
46-
await browser.close();
47-
await new Promise((resolve) => {
48-
compiler.close(resolve);
49-
});
50-
});
51-
52-
it("should not start the server multiple times on recompilation", async () => {
53-
const compiler = webpack(config);
54-
const server = new Server({ port });
55-
const setupSpy = jest.spyOn(server, "setup");
56-
const listenSpy = jest.spyOn(server, "listen");
57-
58-
server.apply(compiler);
59-
60-
const { watching } = await compile(compiler, port);
61-
62-
// Trigger a recompilation by invalidating
63-
await new Promise((resolve) => {
64-
watching.invalidate(() => {
65-
resolve();
66-
});
67-
});
68-
69-
// Wait for the recompilation to finish
70-
await new Promise((resolve) => {
71-
setTimeout(resolve, 2000);
72-
});
73-
74-
expect(setupSpy).toHaveBeenCalledTimes(1);
75-
expect(listenSpy).toHaveBeenCalledTimes(1);
76-
77-
setupSpy.mockRestore();
78-
listenSpy.mockRestore();
79-
await new Promise((resolve) => {
80-
compiler.close(resolve);
81-
});
82-
});
83-
84-
it("should stop the server cleanly via compiler.close()", async () => {
85-
const compiler = webpack(config);
86-
const server = new Server({ port });
87-
const stopSpy = jest.spyOn(server, "stop");
88-
89-
server.apply(compiler);
90-
91-
await compile(compiler, port);
92-
93-
await new Promise((resolve) => {
94-
compiler.close(resolve);
95-
});
96-
97-
expect(stopSpy).toHaveBeenCalledTimes(1);
98-
stopSpy.mockRestore();
99-
});
100-
101-
describe("plugin in webpack config", () => {
102-
it("should work when added to webpack config plugins array", async (t) => {
103-
const server = new Server({ port });
104-
const compiler = webpack({
105-
...config,
106-
plugins: [...config.plugins, server],
107-
});
108-
109-
await compile(compiler, port);
110-
111-
const { page, browser } = await runBrowser();
112-
113-
try {
114-
const pageErrors = [];
115-
const consoleMessages = [];
116-
117-
page
118-
.on("console", (message) => {
119-
consoleMessages.push(message);
120-
})
121-
.on("pageerror", (error) => {
122-
pageErrors.push(error);
123-
});
124-
125-
await page.goto(`http://127.0.0.1:${port}/`, {
126-
waitUntil: "networkidle0",
127-
});
128-
129-
t.assert.snapshot(consoleMessages.map((message) => message.text()));
130-
t.assert.snapshot(pageErrors);
131-
} finally {
132-
await browser.close();
133-
await new Promise((resolve) => {
134-
compiler.close(resolve);
135-
});
136-
}
137-
});
138-
139-
it("should work with output.clean: true", async (t) => {
140-
const server = new Server({ port });
141-
const compiler = webpack({
142-
...config,
143-
output: {
144-
...config.output,
145-
clean: true,
146-
},
147-
plugins: [...config.plugins, server],
148-
});
149-
150-
await compile(compiler, port);
151-
152-
const { page, browser } = await runBrowser();
153-
154-
try {
155-
const pageErrors = [];
156-
const consoleMessages = [];
157-
158-
page
159-
.on("console", (message) => {
160-
consoleMessages.push(message);
161-
})
162-
.on("pageerror", (error) => {
163-
pageErrors.push(error);
164-
});
165-
166-
const response = await page.goto(`http://127.0.0.1:${port}/`, {
167-
waitUntil: "networkidle0",
168-
});
169-
170-
expect(response.status()).toBe(200);
171-
t.assert.snapshot(consoleMessages.map((message) => message.text()));
172-
t.assert.snapshot(pageErrors);
173-
} finally {
174-
await browser.close();
175-
await new Promise((resolve) => {
176-
compiler.close(resolve);
177-
});
178-
}
179-
});
180-
});
181-
18217
describe("WEBPACK_SERVE environment variable", () => {
18318
const OLD_ENV = process.env;
18419
let server;

0 commit comments

Comments
 (0)