-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
311 additions
and
36 deletions.
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 217 bytes [emitted] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
first (webpack x.x.x) compiled successfully in <compiler time> ms | ||
|
||
second: | ||
asset ./dist-second.js 221 bytes [emitted] (name: main) | ||
./src/second.js 51 bytes [built] [code generated] | ||
second (webpack x.x.x) compiled successfully in <compiler 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 217 bytes [compared for emit] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
webpack x.x.x compiled successfully in <compiler time> ms" | ||
`; | ||
|
||
exports[`"bail" option should log warning in watch mode: stdout 2`] = ` | ||
"asset main.js 217 bytes [compared for emit] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
webpack x.x.x compiled successfully in <compiler 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 217 bytes [emitted] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
webpack x.x.x compiled successfully in <compiler 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 217 bytes [compared for emit] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
webpack x.x.x compiled successfully in <compiler time> ms" | ||
`; | ||
|
||
exports[`"bail" option should not log warning without the "bail" option: stdout 2`] = ` | ||
"asset main.js 217 bytes [compared for emit] (name: main) | ||
./src/first.js 50 bytes [built] [code generated] | ||
webpack x.x.x compiled successfully in <compiler 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
'use strict'; | ||
|
||
const { runWatch } = require('../../utils/test-utils'); | ||
const { runWatch, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); | ||
|
||
describe('"bail" option', () => { | ||
it('should not log warning in not watch mode without the "watch" option', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'watch-webpack.config.js']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
|
||
it('should not log warning without the "bail" option', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
|
||
it('should not log warning without the "bail" option', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']); | ||
|
||
expect(stderr).toBeFalsy(); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
|
||
it('should log warning in watch mode', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']); | ||
|
||
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
|
||
it('should log warning in watch mode', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']); | ||
|
||
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
|
||
it('should log warning in case of multiple compilers', async () => { | ||
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js']); | ||
|
||
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); | ||
expect(stdout).toBeTruthy(); | ||
expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); | ||
expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); | ||
}); | ||
}); |
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/" | ||
`; |
36 changes: 36 additions & 0 deletions
36
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,36 @@ | ||
// 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 31 bytes [emitted] [minimized] (name: main) | ||
./src/index.js 32 bytes [built] [code generated] | ||
|
||
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/ | ||
|
||
webpack x.x.x compiled with 1 warning in <compiler time> ms" | ||
`; |
Oops, something went wrong.