forked from webpack/webpack-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
infrastructure-logging.test.js
42 lines (33 loc) · 1.67 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
'use strict';
const { run } = 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'`);
});
});