-
-
Notifications
You must be signed in to change notification settings - Fork 667
Expand file tree
/
Copy pathstats.test.js
More file actions
37 lines (33 loc) · 1.37 KB
/
stats.test.js
File metadata and controls
37 lines (33 loc) · 1.37 KB
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
/* eslint-disable node/no-extraneous-require */
/* eslint-disable node/no-unpublished-require */
'use strict';
const { run } = require('../../utils/test-utils');
const { version } = require('webpack');
const presets = ['normal', 'detailed', 'errors-only', 'errors-warnings', 'minimal', 'verbose', 'none'];
describe('stats flag', () => {
for (const preset of presets) {
it(`should accept --stats "${preset}"`, () => {
const { stderr, stdout } = run(__dirname, ['--stats', `${preset}`]);
expect(stderr).toBeFalsy();
if (version.startsWith('5')) {
expect(stdout).toContain(`stats: { preset: '${preset}' }`);
} else {
expect(stdout).toContain(`stats: '${preset}'`);
}
});
}
it('should accept stats as boolean', () => {
const { stderr, stdout } = run(__dirname, ['--stats']);
expect(stderr).toBeFalsy();
if (version.startsWith('5')) {
expect(stdout).toContain(`stats: { preset: 'normal' }`);
} else {
expect(stdout).toContain('stats: true');
}
});
it('should warn when an unknown flag stats value is passed', () => {
const { stderr } = run(__dirname, ['--stats', 'foo']);
expect(stderr).toBeTruthy();
expect(stderr).toContain('* configuration.stats should be one of these:');
});
});