/
bail.test.js
88 lines (71 loc) · 4.37 KB
/
bail.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
const { run, runWatch } = require('../utils/test-utils');
describe('bail and watch warning', () => {
it('should not log warning in not watch mode', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'bail-webpack.config.js']);
expect(exitCode).toEqual(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
it('should not log warning in not watch mode without the "bail" option', async () => {
const { exitCode, stderr, stdout } = await run(__dirname, ['-c', 'no-bail-webpack.config.js']);
expect(exitCode).toEqual(0);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
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).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
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).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
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).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).not.toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
it('should log warning in watch mode', async () => {
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-webpack.config.js', '--watch']);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
it('should log warning in watch mode', async () => {
const { stderr, stdout } = await runWatch(__dirname, ['-c', 'bail-and-watch-webpack.config.js']);
expect(stderr).toContain('Compilation starting...');
expect(stderr).toContain('Compilation finished');
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
it('should log warning in case of multiple compilers', async () => {
const { stderr, stdout } = await runWatch(
__dirname,
['-c', 'multi-webpack.config.js'],
true,
"Compiler 'second' is watching files for updates...",
);
expect(stderr).toContain("Compilation 'first' starting...");
expect(stderr).toContain("Compilation 'first' finished");
expect(stderr).toContain("Compiler 'first' is watching files for updates...");
expect(stderr).toContain("Compilation 'second' starting...");
expect(stderr).toContain("Compilation 'second' finished");
expect(stderr).toContain("Compiler 'second' is watching files for updates...");
expect(stderr).toContain(`You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.`);
expect(stdout).toBeTruthy();
});
});