Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: refactor test/e2e/states.test.js
WIP: will rename the test and clean it up after i received a feedback from maintainers
- Loading branch information
1 parent
e690789
commit f371ae6
Showing
10 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...s-snapshots/stats-should-work-and-respect-the-ignoreWarnings-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...ots/stats-should-work-using-assets-false-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...stats-should-work-using-colors-green-32m-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...hots/stats-should-work-using-errors-only-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...-snapshots/stats-should-work-using-false-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...pshots/stats-should-work-using-undefined-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...est.js-snapshots/stats-should-work-using-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...ts-should-work-using-warningsFilter-test-value-for-the-stats-option-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
1 change: 1 addition & 0 deletions
1
...tor.test.js-snapshots/stats-should-work-when-stats-is-not-specified-1-chromium-darwin.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["[webpack-dev-server] Server started: Hot Module Replacement enabled, Live Reloading enabled, Progress disabled, Overlay enabled.","[HMR] Waiting for update signal from WDS...","Hey."] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
"use strict"; | ||
|
||
const webpack = require("webpack"); | ||
const Server = require("../../lib/Server"); | ||
const config = require("../fixtures/client-config/webpack.config"); | ||
const HTMLGeneratorPlugin = require("../helpers/html-generator-plugin"); | ||
const port = require("../ports-map").stats; | ||
const { test } = require("@playwright/test"); | ||
const { describe } = require("@playwright/test"); | ||
const { expect } = require("@playwright/test"); | ||
|
||
describe("stats", () => { | ||
const cases = [ | ||
{ | ||
title: 'should work when "stats" is not specified', | ||
webpackOptions: {}, | ||
}, | ||
{ | ||
title: 'should work using "{}" value for the "stats" option', | ||
webpackOptions: { | ||
stats: {}, | ||
}, | ||
}, | ||
{ | ||
title: 'should work using "undefined" value for the "stats" option', | ||
webpackOptions: { | ||
// eslint-disable-next-line no-undefined | ||
stats: undefined, | ||
}, | ||
}, | ||
{ | ||
title: 'should work using "false" value for the "stats" option', | ||
webpackOptions: { | ||
stats: false, | ||
}, | ||
}, | ||
{ | ||
title: 'should work using "errors-only" value for the "stats" option', | ||
webpackOptions: { | ||
stats: "errors-only", | ||
}, | ||
}, | ||
{ | ||
title: | ||
'should work using "{ assets: false }" value for the "stats" option', | ||
webpackOptions: { | ||
stats: { | ||
assets: false, | ||
}, | ||
}, | ||
}, | ||
{ | ||
title: | ||
'should work using "{ colors: { green: "\u001b[32m" }}" value for the "stats" option', | ||
webpackOptions: { | ||
stats: { | ||
colors: { | ||
green: "\u001b[32m", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
title: | ||
'should work using "{ warningsFilter: \'test\' }" value for the "stats" option', | ||
webpackOptions: { | ||
plugins: [ | ||
{ | ||
apply(compiler) { | ||
compiler.hooks.thisCompilation.tap( | ||
"warnings-webpack-plugin", | ||
(compilation) => { | ||
compilation.warnings.push( | ||
new Error("Warning from compilation"), | ||
); | ||
}, | ||
); | ||
}, | ||
}, | ||
new HTMLGeneratorPlugin(), | ||
], | ||
stats: { warningsFilter: /Warning from compilation/ }, | ||
}, | ||
}, | ||
]; | ||
|
||
if (webpack.version.startsWith("5")) { | ||
cases.push({ | ||
title: 'should work and respect the "ignoreWarnings" option', | ||
webpackOptions: { | ||
plugins: [ | ||
{ | ||
apply(compiler) { | ||
compiler.hooks.thisCompilation.tap( | ||
"warnings-webpack-plugin", | ||
(compilation) => { | ||
compilation.warnings.push( | ||
new Error("Warning from compilation"), | ||
); | ||
}, | ||
); | ||
}, | ||
}, | ||
new HTMLGeneratorPlugin(), | ||
], | ||
ignoreWarnings: [/Warning from compilation/], | ||
}, | ||
}); | ||
} | ||
|
||
cases.forEach((testCase) => { | ||
test(testCase.title, async ({ page }) => { | ||
const compiler = webpack({ ...config, ...testCase.webpackOptions }); | ||
const devServerOptions = { | ||
port, | ||
}; | ||
const server = new Server(devServerOptions, compiler); | ||
|
||
await server.start(); | ||
|
||
try { | ||
const consoleMessages = []; | ||
|
||
page.on("console", (message) => { | ||
consoleMessages.push(message); | ||
}); | ||
|
||
await page.goto(`http://localhost:${port}/`, { | ||
waitUntil: "networkidle0", | ||
}); | ||
|
||
expect( | ||
JSON.stringify(consoleMessages.map((message) => message.text())), | ||
).toMatchSnapshot(); | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
await server.stop(); | ||
} | ||
}) | ||
}) | ||
|
||
}); |