Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed May 9, 2023
1 parent ef554ef commit f72d885
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,14 @@ exports[`basic serve usage should log an error on unknown flag: stderr 1`] = `
exports[`basic serve usage should log an error on unknown flag: stdout 1`] = `""`;

exports[`basic serve usage should log error on using '--watch' flag with serve: stderr 1`] = `
"[webpack-cli] Error: Unknown option '--watch'
[webpack-cli] Run 'webpack --help' to see available commands and options"
`;

exports[`basic serve usage should log error on using '--watch' flag with serve: stdout 1`] = `""`;

exports[`basic serve usage should log error on using '-w' alias with serve: stderr 1`] = `
"[webpack-cli] Error: Unknown option '-w'
[webpack-cli] Run 'webpack --help' to see available commands and options"
"[webpack-cli] No need to use the 'serve' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense.
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): http://<network-ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): http://[<network-ip-v6>]:<port>/
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/test/serve/basic/public' directory"
`;

exports[`basic serve usage should log error on using '-w' alias with serve: stdout 1`] = `""`;

exports[`basic serve usage should log used supplied config with serve: stderr 1`] = `
" [webpack-cli] Compiler starting...
[webpack-cli] Compiler is using config: '<cwd>/test/serve/basic/log.config.js'
Expand All @@ -34,6 +29,15 @@ exports[`basic serve usage should log used supplied config with serve: stderr 1`
[webpack-cli] Compiler is watching files for updates..."
`;

exports[`basic serve usage should log warning on using '-w' alias with serve: stderr 1`] = `
"[webpack-cli] No need to use the 'serve' command together with '{ watch: true | false }' or '--watch'/'--no-watch' configuration, it does not make sense.
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
<i> [webpack-dev-server] On Your Network (IPv4): http://<network-ip-v4>:<port>/
<i> [webpack-dev-server] On Your Network (IPv6): http://[<network-ip-v6>]:<port>/
<i> [webpack-dev-server] Content not from webpack is served from '<cwd>/test/serve/basic/public' directory"
`;

exports[`basic serve usage should respect the "publicPath" option from configuration (from the "devServer" options): stderr 1`] = `
"<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:<port>/
Expand Down
12 changes: 7 additions & 5 deletions test/serve/basic/serve-basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,19 @@ describe("basic serve usage", () => {
it("should log error on using '--watch' flag with serve", async () => {
const { exitCode, stdout, stderr } = await runWatch(testPath, ["serve", "--watch"]);

expect(exitCode).toBe(2);
expect(exitCode).toBe(0);
expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
expect(stdout).toContain("HotModuleReplacementPlugin");
expect(stdout).toContain("main.js");
});

it("should log error on using '-w' alias with serve", async () => {
it("should log warning on using '-w' alias with serve", async () => {
const { exitCode, stdout, stderr } = await runWatch(testPath, ["serve", "-w"]);

expect(exitCode).toBe(2);
expect(exitCode).toBe(0);
expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
expect(stdout).toContain("HotModuleReplacementPlugin");
expect(stdout).toContain("main.js");
});

it("should log an error on unknown flag", async () => {
Expand Down

0 comments on commit f72d885

Please sign in to comment.