Skip to content

Commit 21227e3

Browse files
authored
test: migrate watchFiles test on HTMLGeneratorPlugin (#4207)
* test: migrate `watchFiles` test on `HTMLGeneratorPlugin` * test: migrate `watchFiles` test on `HTMLGeneratorPlugin` * chore: refactor
1 parent 0aca07b commit 21227e3

File tree

10 files changed

+38
-10
lines changed

10 files changed

+38
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ yarn-error.log
1616
.eslintcache
1717

1818
test/fixtures/static-config/public/assets/non-exist.txt
19+
test/fixtures/watch-files-config/public/assets/non-exist.txt
1920
test/fixtures/reload-config/main.css
2021
test/fixtures/reload-config-2/main.css
2122
!/test/fixtures/static-config/public/node_modules

test/e2e/watch-files.test.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,14 @@ const chokidar = require("chokidar");
55
const fs = require("graceful-fs");
66
const webpack = require("webpack");
77
const Server = require("../../lib/Server");
8-
const config = require("../fixtures/static-config/webpack.config");
8+
const config = require("../fixtures/watch-files-config/webpack.config");
99
const runBrowser = require("../helpers/run-browser");
1010
const port = require("../ports-map")["watch-files-option"];
1111

12-
const watchDir = path.resolve(__dirname, "../fixtures/static-config/public");
12+
const watchDir = path.resolve(
13+
__dirname,
14+
"../fixtures/watch-files-config/public"
15+
);
1316

1417
describe("watchFiles option", () => {
1518
describe("should work with string and path to file", () => {
@@ -55,7 +58,7 @@ describe("watchFiles option", () => {
5558
pageErrors.push(error);
5659
});
5760

58-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
61+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
5962
waitUntil: "networkidle0",
6063
});
6164

@@ -126,7 +129,7 @@ describe("watchFiles option", () => {
126129
pageErrors.push(error);
127130
});
128131

129-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
132+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
130133
waitUntil: "networkidle0",
131134
});
132135

@@ -197,7 +200,7 @@ describe("watchFiles option", () => {
197200
pageErrors.push(error);
198201
});
199202

200-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
203+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
201204
waitUntil: "networkidle0",
202205
});
203206

@@ -273,7 +276,7 @@ describe("watchFiles option", () => {
273276
pageErrors.push(error);
274277
});
275278

276-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
279+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
277280
waitUntil: "networkidle0",
278281
});
279282

@@ -349,7 +352,7 @@ describe("watchFiles option", () => {
349352
pageErrors.push(error);
350353
});
351354

352-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
355+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
353356
waitUntil: "networkidle0",
354357
});
355358

@@ -422,7 +425,7 @@ describe("watchFiles option", () => {
422425
pageErrors.push(error);
423426
});
424427

425-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
428+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
426429
waitUntil: "networkidle0",
427430
});
428431

@@ -503,7 +506,7 @@ describe("watchFiles option", () => {
503506
pageErrors.push(error);
504507
});
505508

506-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
509+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
507510
waitUntil: "networkidle0",
508511
});
509512

@@ -644,7 +647,7 @@ describe("watchFiles option", () => {
644647
pageErrors.push(error);
645648
});
646649

647-
const response = await page.goto(`http://127.0.0.1:${port}/main`, {
650+
const response = await page.goto(`http://127.0.0.1:${port}/`, {
648651
waitUntil: "networkidle0",
649652
});
650653

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use strict";
2+
3+
console.log("Hey.");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Foo!

test/fixtures/watch-files-config/public/assets/example.txt

Whitespace-only changes.

test/fixtures/watch-files-config/public/assets/other.txt

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Heyo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Other html
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Heyo.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
"use strict";
2+
3+
const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin");
4+
5+
module.exports = {
6+
mode: "development",
7+
context: __dirname,
8+
stats: "none",
9+
entry: "./foo.js",
10+
output: {
11+
publicPath: "/",
12+
},
13+
infrastructureLogging: {
14+
level: "warn",
15+
},
16+
plugins: [new HTMLGeneratorPlugin()],
17+
};

0 commit comments

Comments
 (0)