Skip to content

Commit 55cc10d

Browse files
test: update
1 parent 15ae06d commit 55cc10d

File tree

4 files changed

+77
-10
lines changed

4 files changed

+77
-10
lines changed

test/e2e/__snapshots__/entry.test.js.snap.webpack4

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ Array [
2222

2323
exports[`entry should work with dynamic entry: page errors 1`] = `Array []`;
2424

25+
exports[`entry should work with empty: console messages 1`] = `
26+
Array [
27+
"[HMR] Waiting for update signal from WDS...",
28+
"Hey.",
29+
"[webpack-dev-server] Hot Module Replacement enabled.",
30+
"[webpack-dev-server] Live Reloading enabled.",
31+
]
32+
`;
33+
34+
exports[`entry should work with empty: page errors 1`] = `Array []`;
35+
2536
exports[`entry should work with multiple entries #2: console messages 1`] = `
2637
Array [
2738
"[HMR] Waiting for update signal from WDS...",
@@ -33,6 +44,18 @@ Array [
3344

3445
exports[`entry should work with multiple entries #2: page errors 1`] = `Array []`;
3546

47+
exports[`entry should work with multiple entries and "dependOn": console messages 1`] = `
48+
Array [
49+
"[HMR] Waiting for update signal from WDS...",
50+
"Bar.",
51+
"[webpack-dev-server] Hot Module Replacement enabled.",
52+
"[webpack-dev-server] Live Reloading enabled.",
53+
"Hey.",
54+
]
55+
`;
56+
57+
exports[`entry should work with multiple entries and "dependOn": page errors 1`] = `Array []`;
58+
3659
exports[`entry should work with multiple entries: console messages 1`] = `
3760
Array [
3861
"[HMR] Waiting for update signal from WDS...",
@@ -44,6 +67,17 @@ Array [
4467

4568
exports[`entry should work with multiple entries: page errors 1`] = `Array []`;
4669

70+
exports[`entry should work with object entry: console messages 1`] = `
71+
Array [
72+
"[HMR] Waiting for update signal from WDS...",
73+
"Hey.",
74+
"[webpack-dev-server] Hot Module Replacement enabled.",
75+
"[webpack-dev-server] Live Reloading enabled.",
76+
]
77+
`;
78+
79+
exports[`entry should work with object entry: page errors 1`] = `Array []`;
80+
4781
exports[`entry should work with single array entry: console messages 1`] = `
4882
Array [
4983
"[HMR] Waiting for update signal from WDS...",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ exports[`entry should work with multiple entries #2: page errors 1`] = `Array []
4747
exports[`entry should work with multiple entries and "dependOn": console messages 1`] = `
4848
Array [
4949
"[HMR] Waiting for update signal from WDS...",
50-
"Hey.",
5150
"Bar.",
5251
"[webpack-dev-server] Hot Module Replacement enabled.",
5352
"[webpack-dev-server] Live Reloading enabled.",
53+
"Hey.",
5454
]
5555
`;
5656

test/e2e/entry.test.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,11 @@ describe('entry', () => {
352352
pageErrors.push(error);
353353
});
354354

355-
await page.reload({ waitUntil: 'networkidle0' });
356-
await page.goto(`http://127.0.0.1:${port}/foo`, {
355+
await page.goto(`http://127.0.0.1:${port}/test.html`, {
357356
waitUntil: 'networkidle0',
358357
});
359358
await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` });
360-
await page.reload({ waitUntil: 'networkidle0' });
359+
await page.addScriptTag({ url: `http://127.0.0.1:${port}/foo.js` });
361360

362361
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
363362
'console messages'
@@ -422,12 +421,11 @@ describe('entry', () => {
422421
pageErrors.push(error);
423422
});
424423

425-
await page.reload({ waitUntil: 'networkidle0' });
426-
await page.goto(`http://127.0.0.1:${port}/bar`, {
424+
await page.goto(`http://127.0.0.1:${port}/test.html`, {
427425
waitUntil: 'networkidle0',
428426
});
429427
await page.addScriptTag({ url: `http://127.0.0.1:${port}/runtime.js` });
430-
await page.reload({ waitUntil: 'networkidle0' });
428+
await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` });
431429

432430
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
433431
'console messages'
@@ -492,12 +490,11 @@ describe('entry', () => {
492490
pageErrors.push(error);
493491
});
494492

495-
await page.reload({ waitUntil: 'networkidle0' });
496-
await page.goto(`http://127.0.0.1:${port}/main`, {
493+
await page.goto(`http://127.0.0.1:${port}/test.html`, {
497494
waitUntil: 'networkidle0',
498495
});
499496
await page.addScriptTag({ url: `http://127.0.0.1:${port}/bar.js` });
500-
await page.reload({ waitUntil: 'networkidle0' });
497+
await page.addScriptTag({ url: `http://127.0.0.1:${port}/main.js` });
501498

502499
expect(consoleMessages.map((message) => message.text())).toMatchSnapshot(
503500
'console messages'

test/fixtures/client-config/webpack.config.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
'use strict';
22

3+
const HTMLContent = `
4+
<!doctype html>
5+
<html>
6+
<head>
7+
<meta charset='UTF-8'>
8+
<title>test</title>
9+
</head>
10+
<body></body>
11+
</html>
12+
`;
13+
314
module.exports = {
415
mode: 'development',
516
context: __dirname,
@@ -11,4 +22,29 @@ module.exports = {
1122
infrastructureLogging: {
1223
level: 'warn',
1324
},
25+
plugins: [
26+
{
27+
apply(compiler) {
28+
const pluginName = 'html-generator-plugin-test';
29+
30+
compiler.hooks.thisCompilation.tap(pluginName, (compilation) => {
31+
const { RawSource } = compiler.webpack.sources;
32+
33+
compilation.hooks.processAssets.tap(
34+
{
35+
name: pluginName,
36+
stage:
37+
compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONAL,
38+
},
39+
() => {
40+
const filename = 'test.html';
41+
const source = new RawSource(HTMLContent);
42+
43+
compilation.emitAsset(filename, source);
44+
}
45+
);
46+
});
47+
},
48+
},
49+
],
1450
};

0 commit comments

Comments
 (0)