Skip to content

Commit

Permalink
test: migrate watchFiles test on HTMLGeneratorPlugin (#4207)
Browse files Browse the repository at this point in the history
* test: migrate `watchFiles` test on `HTMLGeneratorPlugin`

* test: migrate `watchFiles` test on `HTMLGeneratorPlugin`

* chore: refactor
  • Loading branch information
snitin315 committed Jan 20, 2022
1 parent 0aca07b commit 21227e3
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 13 additions & 10 deletions test/e2e/watch-files.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down Expand Up @@ -55,7 +58,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",
});

Expand Down Expand Up @@ -126,7 +129,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",
});

Expand Down Expand Up @@ -197,7 +200,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",
});

Expand Down Expand Up @@ -273,7 +276,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",
});

Expand Down Expand Up @@ -349,7 +352,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",
});

Expand Down Expand Up @@ -422,7 +425,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",
});

Expand Down Expand Up @@ -503,7 +506,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",
});

Expand Down Expand Up @@ -644,7 +647,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",
});

Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/watch-files-config/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use strict";

console.log("Hey.");
1 change: 1 addition & 0 deletions test/fixtures/watch-files-config/other/foo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Foo!
Empty file.
Empty file.
1 change: 1 addition & 0 deletions test/fixtures/watch-files-config/public/bar/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Heyo
1 change: 1 addition & 0 deletions test/fixtures/watch-files-config/public/other.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Other html
1 change: 1 addition & 0 deletions test/fixtures/watch-files-config/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Heyo.
17 changes: 17 additions & 0 deletions test/fixtures/watch-files-config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -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()],
};

0 comments on commit 21227e3

Please sign in to comment.