/
no-stats.test.js
39 lines (32 loc) · 1.46 KB
/
no-stats.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
'use strict';
const { run } = require('../../utils/test-utils');
const { version } = require('webpack');
describe('stats flag', () => {
it('should accept --no-stats as boolean', () => {
const { stderr, stdout } = run(__dirname, ['--no-stats']);
expect(stderr).toBeFalsy();
if (version.startsWith('5')) {
expect(stdout).toContain(`stats: { preset: 'none' }`);
} else {
expect(stdout).toContain('stats: false');
}
});
it('should warn and use --no-stats when stats and no-stats both are provided', () => {
const { stderr, stdout } = run(__dirname, ['--stats', 'verbose', '--no-stats']);
expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`);
if (version.startsWith('5')) {
expect(stdout).toContain(`stats: { preset: 'none' }`);
} else {
expect(stdout).toContain('stats: false');
}
});
it('should warn and use --stats when stats and no-stats both are provided', () => {
const { stderr, stdout } = run(__dirname, ['--no-stats', '--stats', 'verbose']);
expect(stderr).toContain(`You provided both --stats and --no-stats. We will use only the last of these flags`);
if (version.startsWith('5')) {
expect(stdout).toContain(`stats: { preset: 'verbose' }`);
} else {
expect(stdout).toContain(`stats: 'verbose'`);
}
});
});