forked from webpack/webpack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infrastructure-logging.test.js
83 lines (68 loc) · 3.11 KB
/
infrastructure-logging.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
'use strict';
const { run, runWatch } = require('../utils/test-utils');
const { resolve } = require('path');
describe('infrastructure logging related flag', () => {
it('should set infrastructureLogging.debug properly', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug', 'myPlugin']);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`debug: [ 'myPlugin' ]`);
});
it('should reset infrastructureLogging.debug to []', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-debug-reset']);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain(`debug: []`);
});
it('should set infrastructureLogging.level properly', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-level', 'log']);
expect(exitCode).toBe(0);
expect(stderr).toContain("Compilation 'compiler' starting...");
expect(stderr).toContain("Compilation 'compiler' finished");
expect(stdout).toContain(`level: 'log'`);
});
it('should log used default config when level is log', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--infrastructure-logging-level', 'log']);
expect(exitCode).toBe(0);
const configPath = resolve(__dirname, './webpack.config.js');
expect(stderr).toContain("Compilation 'compiler' starting...");
expect(stderr).toContain(`Using config ${configPath}`);
expect(stderr).toContain("Compilation 'compiler' finished");
expect(stdout).toContain(`level: 'log'`);
});
it('should log used supplied config when level is log', () => {
const { exitCode, stderr, stdout } = run(__dirname, [
'--config',
'webpack.cache.config.js',
'--infrastructure-logging-level',
'log',
]);
expect(exitCode).toBe(0);
const configPath = resolve(__dirname, './webpack.cache.config.js');
expect(stderr).toContain(`Using config ${configPath}`);
expect(stdout).toContain(`level: 'log'`);
});
it('should log used supplied config with watch', async () => {
const { stderr, stdout } = await runWatch(__dirname, [
'--config',
'webpack.cache.config.js',
'--infrastructure-logging-level',
'log',
]);
const configPath = resolve(__dirname, './webpack.cache.config.js');
expect(stderr).toContain(`Using config ${configPath}`);
expect(stdout).toContain(`level: 'log'`);
});
it('should log used supplied config with serve', async () => {
const { stderr, stdout } = await runWatch(__dirname, [
'serve',
'--config',
'webpack.cache.config.js',
'--infrastructure-logging-level',
'log',
]);
const configPath = resolve(__dirname, './webpack.cache.config.js');
expect(stderr).toContain(`Using config ${configPath}`);
expect(stdout).toContain(`level: 'log'`);
});
});