/
start-finish-force-log.test.js
50 lines (45 loc) · 2.14 KB
/
start-finish-force-log.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
'use strict';
const { run, runWatch, isWebpack5 } = require('../../utils/test-utils');
describe('start finish force log', () => {
it('start finish force log when env is set', () => {
const { exitCode, stderr, stdout } = run(__dirname, [], {
env: { WEBPACK_CLI_START_FINISH_FORCE_LOG: true },
});
expect(exitCode).toBe(0);
expect(stderr).toContain('Compiler starting...');
expect(stderr).toContain('Compiler finished');
const output = isWebpack5 ? 'compiled successfully' : 'main.js';
expect(stdout).toContain(output);
});
it('should show name of the config', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--name', 'log config'], {
env: { WEBPACK_CLI_START_FINISH_FORCE_LOG: true },
});
expect(exitCode).toBe(0);
expect(stderr).toContain("Compiler 'log config' starting...");
expect(stderr).toContain("Compiler 'log config' finished");
const output = isWebpack5 ? 'compiled successfully' : 'main.js';
expect(stdout).toContain(output);
});
it('should work with watch', async () => {
const { stderr, stdout } = await runWatch(__dirname, ['watch'], {
env: { WEBPACK_CLI_START_FINISH_FORCE_LOG: true },
});
expect(stderr).toContain('Compiler starting...');
expect(stderr).toContain('Compiler finished');
const output = isWebpack5 ? 'compiled successfully' : 'main.js';
expect(stdout).toContain(output);
});
it('should work with multi compiler', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.array.js'], {
env: { WEBPACK_CLI_START_FINISH_FORCE_LOG: true },
});
expect(exitCode).toBe(0);
expect(stderr).toContain("Compiler 'Gojou' starting...");
expect(stderr).toContain("Compiler 'Satoru' starting...");
expect(stderr).toContain("Compiler 'Gojou' finished");
expect(stderr).toContain("Compiler 'Satoru' finished");
const output = isWebpack5 ? 'compiled successfully' : 'main.js';
expect(stdout).toContain(output);
});
});