-
-
Notifications
You must be signed in to change notification settings - Fork 602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: watch option snapshot #2679
Open
anshumanv
wants to merge
2
commits into
master
Choose a base branch
from
watch-snap
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
9 changes: 9 additions & 0 deletions
9
test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack4
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stderr 1`] = `""`; | ||
|
||
exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stdout 1`] = ` | ||
"Webpack Bundle Analyzer is started | ||
at stack | ||
Use Ctrl+C to close it" | ||
`; |
9 changes: 9 additions & 0 deletions
9
test/watch/analyze/__snapshots__/analyze-flag.test.js.snap.webpack5
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,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stderr 1`] = `""`; | ||
|
||
exports[`"analyze" option should load webpack-bundle-analyzer plugin with --analyze flag: stdout 1`] = ` | ||
"Webpack Bundle Analyzer is started | ||
at stack | ||
Use Ctrl+C to close it" | ||
`; |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
"use strict"; | ||
|
||
const { runWatch } = require("../../utils/test-utils"); | ||
const { runWatch, normalizeStderr, normalizeStdout } = require("../../utils/test-utils"); | ||
|
||
describe('"analyze" option', () => { | ||
it("should load webpack-bundle-analyzer plugin with --analyze flag", async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ["--analyze"], { | ||
killString: /Webpack Bundle Analyzer is started at/, | ||
}); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toContain("Webpack Bundle Analyzer is started at"); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot("stderr"); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot("stdout"); | ||
}); | ||
}); |
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,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`"bail" option should log warning in case of multiple compilers: stderr 1`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in case of multiple compilers: stdout 1`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Child first: | ||
Hash: <hash> | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
./dist-first.js 3.77 KiB main [emitted] main | ||
Entrypoint main = ./dist-first.js | ||
[./src/first.js] 50 bytes {main} [built] | ||
Child second: | ||
Hash: <hash> | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
./dist-second.js 3.77 KiB main [emitted] main | ||
Entrypoint main = ./dist-second.js | ||
[./src/second.js] 51 bytes {main} [built]" | ||
`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stderr 1`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stderr 2`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stdout 1`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 3.77 KiB main [emitted] main | ||
Entrypoint main = main.js | ||
[./src/first.js] 50 bytes {main} [built]" | ||
`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stdout 2`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 3.77 KiB main [emitted] main | ||
Entrypoint main = main.js | ||
[./src/first.js] 50 bytes {main} [built]" | ||
`; | ||
|
||
exports[`"bail" option should not log warning in not watch mode without the "watch" option: stderr 1`] = `""`; | ||
|
||
exports[`"bail" option should not log warning in not watch mode without the "watch" option: stdout 1`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 3.77 KiB main [emitted] main | ||
Entrypoint main = main.js | ||
[./src/first.js] 50 bytes {main} [built]" | ||
`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stderr 1`] = `""`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stderr 2`] = `""`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stdout 1`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 3.77 KiB main [emitted] main | ||
Entrypoint main = main.js | ||
[./src/first.js] 50 bytes {main} [built]" | ||
`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stdout 2`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 3.77 KiB main [emitted] main | ||
Entrypoint main = main.js | ||
[./src/first.js] 50 bytes {main} [built]" | ||
`; |
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,55 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`"bail" option should log warning in case of multiple compilers: stderr 1`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in case of multiple compilers: stdout 1`] = ` | ||
"first: | ||
asset ./dist-first.js <size> <size-abbreviation> [emitted] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
first (webpack x.x.x) compiled successfully in <compile-time> ms | ||
|
||
second: | ||
asset ./dist-second.js <size> <size-abbreviation> [emitted] (name: main) | ||
./src/second.js <size> <size-abbreviation> [built] [code generated] | ||
second (webpack x.x.x) compiled successfully in <compile-time> ms" | ||
`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stderr 1`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stderr 2`] = `"<w> [webpack-cli] You are using \\"bail\\" with \\"watch\\". \\"bail\\" will still exit webpack when the first error is found."`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stdout 1`] = ` | ||
"asset main.js <size> <size-abbreviation> [compared for emit] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stdout 2`] = ` | ||
"asset main.js <size> <size-abbreviation> [compared for emit] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; | ||
|
||
exports[`"bail" option should not log warning in not watch mode without the "watch" option: stderr 1`] = `""`; | ||
|
||
exports[`"bail" option should not log warning in not watch mode without the "watch" option: stdout 1`] = ` | ||
"asset main.js <size> <size-abbreviation> [emitted] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stderr 1`] = `""`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stderr 2`] = `""`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stdout 1`] = ` | ||
"asset main.js <size> <size-abbreviation> [compared for emit] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stdout 2`] = ` | ||
"asset main.js <size> <size-abbreviation> [compared for emit] (name: main) | ||
./src/first.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; |
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
39 changes: 39 additions & 0 deletions
39
test/watch/basic/__snapshots__/basic.test.js.snap.webpack4
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,39 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`basic should log supplied config with watch: stderr 1`] = ` | ||
" [webpack-cli] Compiler starting... | ||
[webpack-cli] Compiler is using config: '<cwd>/test/watch/basic/log.config.js' | ||
[webpack-cli] Compiler finished | ||
" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stderr 1`] = ` | ||
"[webpack-cli] Error: Unknown option '--no-watch' | ||
[webpack-cli] Run 'webpack --help' to see available commands and options" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stdout 1`] = `""`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stderr 1`] = ` | ||
"[webpack-cli] Error: Unknown option '--watch' | ||
[webpack-cli] Run 'webpack --help' to see available commands and options" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stdout 1`] = `""`; | ||
|
||
exports[`basic should work with negative value: stderr 1`] = `""`; | ||
|
||
exports[`basic should work with negative value: stdout 1`] = ` | ||
"Hash: <hash> | ||
Version: webpack x.x.x | ||
Time: <compile time> | ||
Built at: <built time> | ||
Asset Size Chunks Chunk Names | ||
main.js 960 bytes 0 [emitted] main | ||
Entrypoint main = main.js | ||
[0] ./src/index.js 32 bytes {0} [built] | ||
|
||
WARNING in configuration | ||
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment. | ||
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/configuration/mode/" | ||
`; |
30 changes: 30 additions & 0 deletions
30
test/watch/basic/__snapshots__/basic.test.js.snap.webpack5
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,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`basic should log supplied config with watch: stderr 1`] = ` | ||
" [webpack-cli] Compiler starting... | ||
[webpack-cli] Compiler is using config: '<cwd>/test/watch/basic/log.config.js' | ||
[webpack-cli] Compiler finished | ||
" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stderr 1`] = ` | ||
"[webpack-cli] Error: Unknown option '--no-watch' | ||
[webpack-cli] Run 'webpack --help' to see available commands and options" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--no-watch\` option and log warning: stdout 1`] = `""`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stderr 1`] = ` | ||
"[webpack-cli] Error: Unknown option '--watch' | ||
[webpack-cli] Run 'webpack --help' to see available commands and options" | ||
`; | ||
|
||
exports[`basic should recompile upon file change using the \`command\` option and the \`--watch\` option and log warning: stdout 1`] = `""`; | ||
|
||
exports[`basic should work with negative value: stderr 1`] = `""`; | ||
|
||
exports[`basic should work with negative value: stdout 1`] = ` | ||
"asset main.js <size> <size-abbreviation> [emitted] (name: main) | ||
./src/index.js <size> <size-abbreviation> [built] [code generated] | ||
webpack x.x.x compiled successfully in <compile-time> ms" | ||
`; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put
normalizeCompileTime
innormalizeV4Output
, ideally we should have two functionnormalizeStatsV4
andnormalizeStatsV5
, v5 default output are simple so we should not have big problems here, If you need I can implement these functions so you will be able to continue adding snapshots and improvenormalizeStats
function using regexpsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep help appreciated, also something wrong with v4 snapshot, thanks!