From 30cb91c6e4adc4735283a8ce050d1cf342ac5a8e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 20 Jan 2022 15:14:43 +0530 Subject: [PATCH 1/3] test: migrate `watchFiles` test on `HTMLGeneratorPlugin` --- test/e2e/watch-files.test.js | 16 ++++++++-------- test/fixtures/static-config/webpack.config.js | 3 +++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/e2e/watch-files.test.js b/test/e2e/watch-files.test.js index 8031a3a963..c94119620f 100644 --- a/test/e2e/watch-files.test.js +++ b/test/e2e/watch-files.test.js @@ -55,7 +55,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -126,7 +126,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -197,7 +197,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -273,7 +273,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -349,7 +349,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -422,7 +422,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -503,7 +503,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); @@ -644,7 +644,7 @@ describe("watchFiles option", () => { pageErrors.push(error); }); - const response = await page.goto(`http://127.0.0.1:${port}/main`, { + const response = await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: "networkidle0", }); diff --git a/test/fixtures/static-config/webpack.config.js b/test/fixtures/static-config/webpack.config.js index e0a2dfdbd5..c31d06071d 100644 --- a/test/fixtures/static-config/webpack.config.js +++ b/test/fixtures/static-config/webpack.config.js @@ -1,5 +1,7 @@ "use strict"; +const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); + module.exports = { mode: "development", context: __dirname, @@ -11,4 +13,5 @@ module.exports = { infrastructureLogging: { level: "warn", }, + plugins: [new HTMLGeneratorPlugin()], }; From 1b28aab35f022f21b1ba4f319f6591669dad0b44 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 20 Jan 2022 16:35:58 +0530 Subject: [PATCH 2/3] test: migrate `watchFiles` test on `HTMLGeneratorPlugin` --- test/e2e/watch-files.test.js | 7 +++++-- test/fixtures/static-config/webpack.config.js | 3 --- test/fixtures/watch-files-config/foo.js | 3 +++ test/fixtures/watch-files-config/other/foo.html | 1 + .../public/assets/example.txt | 0 .../public/assets/non-exist.txt | 1 + .../watch-files-config/public/assets/other.txt | 0 .../watch-files-config/public/bar/index.html | 1 + .../fixtures/watch-files-config/public/foo.wasm | 0 .../watch-files-config/public/other.html | 1 + .../watch-files-config/static/index.html | 1 + .../watch-files-config/webpack.config.js | 17 +++++++++++++++++ 12 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 test/fixtures/watch-files-config/foo.js create mode 100644 test/fixtures/watch-files-config/other/foo.html create mode 100644 test/fixtures/watch-files-config/public/assets/example.txt create mode 100644 test/fixtures/watch-files-config/public/assets/non-exist.txt create mode 100644 test/fixtures/watch-files-config/public/assets/other.txt create mode 100644 test/fixtures/watch-files-config/public/bar/index.html create mode 100644 test/fixtures/watch-files-config/public/foo.wasm create mode 100644 test/fixtures/watch-files-config/public/other.html create mode 100644 test/fixtures/watch-files-config/static/index.html create mode 100644 test/fixtures/watch-files-config/webpack.config.js diff --git a/test/e2e/watch-files.test.js b/test/e2e/watch-files.test.js index c94119620f..ff58b1fbbb 100644 --- a/test/e2e/watch-files.test.js +++ b/test/e2e/watch-files.test.js @@ -5,11 +5,14 @@ const chokidar = require("chokidar"); const fs = require("graceful-fs"); const webpack = require("webpack"); const Server = require("../../lib/Server"); -const config = require("../fixtures/static-config/webpack.config"); +const config = require("../fixtures/watch-files-config/webpack.config"); const runBrowser = require("../helpers/run-browser"); const port = require("../ports-map")["watch-files-option"]; -const watchDir = path.resolve(__dirname, "../fixtures/static-config/public"); +const watchDir = path.resolve( + __dirname, + "../fixtures/watch-files-config/public" +); describe("watchFiles option", () => { describe("should work with string and path to file", () => { diff --git a/test/fixtures/static-config/webpack.config.js b/test/fixtures/static-config/webpack.config.js index c31d06071d..e0a2dfdbd5 100644 --- a/test/fixtures/static-config/webpack.config.js +++ b/test/fixtures/static-config/webpack.config.js @@ -1,7 +1,5 @@ "use strict"; -const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); - module.exports = { mode: "development", context: __dirname, @@ -13,5 +11,4 @@ module.exports = { infrastructureLogging: { level: "warn", }, - plugins: [new HTMLGeneratorPlugin()], }; diff --git a/test/fixtures/watch-files-config/foo.js b/test/fixtures/watch-files-config/foo.js new file mode 100644 index 0000000000..3c915dbcb8 --- /dev/null +++ b/test/fixtures/watch-files-config/foo.js @@ -0,0 +1,3 @@ +"use strict"; + +console.log("Hey."); diff --git a/test/fixtures/watch-files-config/other/foo.html b/test/fixtures/watch-files-config/other/foo.html new file mode 100644 index 0000000000..c57ed97e22 --- /dev/null +++ b/test/fixtures/watch-files-config/other/foo.html @@ -0,0 +1 @@ +Foo! diff --git a/test/fixtures/watch-files-config/public/assets/example.txt b/test/fixtures/watch-files-config/public/assets/example.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/watch-files-config/public/assets/non-exist.txt b/test/fixtures/watch-files-config/public/assets/non-exist.txt new file mode 100644 index 0000000000..9c6e47bc1f --- /dev/null +++ b/test/fixtures/watch-files-config/public/assets/non-exist.txt @@ -0,0 +1 @@ +Kurosaki Ichigo \ No newline at end of file diff --git a/test/fixtures/watch-files-config/public/assets/other.txt b/test/fixtures/watch-files-config/public/assets/other.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/watch-files-config/public/bar/index.html b/test/fixtures/watch-files-config/public/bar/index.html new file mode 100644 index 0000000000..17654db5a1 --- /dev/null +++ b/test/fixtures/watch-files-config/public/bar/index.html @@ -0,0 +1 @@ +Heyo diff --git a/test/fixtures/watch-files-config/public/foo.wasm b/test/fixtures/watch-files-config/public/foo.wasm new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/watch-files-config/public/other.html b/test/fixtures/watch-files-config/public/other.html new file mode 100644 index 0000000000..6b31da1a64 --- /dev/null +++ b/test/fixtures/watch-files-config/public/other.html @@ -0,0 +1 @@ +Other html diff --git a/test/fixtures/watch-files-config/static/index.html b/test/fixtures/watch-files-config/static/index.html new file mode 100644 index 0000000000..20f073ee9d --- /dev/null +++ b/test/fixtures/watch-files-config/static/index.html @@ -0,0 +1 @@ +Heyo. diff --git a/test/fixtures/watch-files-config/webpack.config.js b/test/fixtures/watch-files-config/webpack.config.js new file mode 100644 index 0000000000..c31d06071d --- /dev/null +++ b/test/fixtures/watch-files-config/webpack.config.js @@ -0,0 +1,17 @@ +"use strict"; + +const HTMLGeneratorPlugin = require("../../helpers/html-generator-plugin"); + +module.exports = { + mode: "development", + context: __dirname, + stats: "none", + entry: "./foo.js", + output: { + publicPath: "/", + }, + infrastructureLogging: { + level: "warn", + }, + plugins: [new HTMLGeneratorPlugin()], +}; From 27b27750641d35d8df067d1804ed451c811110c6 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Thu, 20 Jan 2022 16:55:47 +0530 Subject: [PATCH 3/3] chore: refactor --- .gitignore | 1 + test/fixtures/watch-files-config/public/assets/non-exist.txt | 1 - test/fixtures/watch-files-config/public/foo.wasm | 0 3 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 test/fixtures/watch-files-config/public/assets/non-exist.txt delete mode 100644 test/fixtures/watch-files-config/public/foo.wasm diff --git a/.gitignore b/.gitignore index 41247690e6..2245f4db71 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ yarn-error.log .eslintcache test/fixtures/static-config/public/assets/non-exist.txt +test/fixtures/watch-files-config/public/assets/non-exist.txt test/fixtures/reload-config/main.css test/fixtures/reload-config-2/main.css !/test/fixtures/static-config/public/node_modules diff --git a/test/fixtures/watch-files-config/public/assets/non-exist.txt b/test/fixtures/watch-files-config/public/assets/non-exist.txt deleted file mode 100644 index 9c6e47bc1f..0000000000 --- a/test/fixtures/watch-files-config/public/assets/non-exist.txt +++ /dev/null @@ -1 +0,0 @@ -Kurosaki Ichigo \ No newline at end of file diff --git a/test/fixtures/watch-files-config/public/foo.wasm b/test/fixtures/watch-files-config/public/foo.wasm deleted file mode 100644 index e69de29bb2..0000000000