|
1 | 1 | 'use strict';
|
2 | 2 |
|
3 |
| -const { runWatch } = require('../../utils/test-utils'); |
| 3 | +const { runWatch, normalizeStderr, normalizeStdout } = require('../../utils/test-utils'); |
4 | 4 |
|
5 | 5 | describe('"bail" option', () => {
|
6 | 6 | it('should not log warning in not watch mode without the "watch" option', async () => {
|
7 | 7 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'watch-webpack.config.js']);
|
8 | 8 |
|
9 |
| - expect(stderr).toBeFalsy(); |
10 |
| - expect(stdout).toBeTruthy(); |
| 9 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 10 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
11 | 11 | });
|
12 | 12 |
|
13 | 13 | it('should not log warning without the "bail" option', async () => {
|
14 | 14 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']);
|
15 | 15 |
|
16 |
| - expect(stderr).toBeFalsy(); |
17 |
| - expect(stdout).toBeTruthy(); |
| 16 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 17 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
18 | 18 | });
|
19 | 19 |
|
20 | 20 | it('should not log warning without the "bail" option', async () => {
|
21 | 21 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'no-bail-webpack.config.js', '--watch']);
|
22 | 22 |
|
23 |
| - expect(stderr).toBeFalsy(); |
24 |
| - expect(stdout).toBeTruthy(); |
| 23 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 24 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
25 | 25 | });
|
26 | 26 |
|
27 | 27 | it('should log warning in watch mode', async () => {
|
28 | 28 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']);
|
29 | 29 |
|
30 |
| - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); |
31 |
| - expect(stdout).toBeTruthy(); |
| 30 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 31 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
32 | 32 | });
|
33 | 33 |
|
34 | 34 | it('should log warning in watch mode', async () => {
|
35 | 35 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']);
|
36 | 36 |
|
37 |
| - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); |
38 |
| - expect(stdout).toBeTruthy(); |
| 37 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 38 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
39 | 39 | });
|
40 | 40 |
|
41 | 41 | it('should log warning in case of multiple compilers', async () => {
|
42 | 42 | const { stderr, stdout } = await runWatch(__dirname, ['-c', 'multi-webpack.config.js']);
|
43 | 43 |
|
44 |
| - expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`); |
45 |
| - expect(stdout).toBeTruthy(); |
| 44 | + expect(normalizeStderr(stderr)).toMatchSnapshot('stderr'); |
| 45 | + expect(normalizeStdout(stdout)).toMatchSnapshot('stdout'); |
46 | 46 | });
|
47 | 47 | });
|
0 commit comments