-
-
Notifications
You must be signed in to change notification settings - Fork 590
/
configtest.test.js
47 lines (36 loc) · 1.85 KB
/
configtest.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
'use strict';
const { run } = require('../utils/test-utils');
describe('basic info usage', () => {
it('should validate webpack config successfully', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './webpack.config.js'], false);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toContain('There are no validation errors in the given webpack configuration.');
});
it('should throw validation error', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './error.config.js'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain('ValidationError: Invalid configuration object.');
expect(stderr).toContain('configuration.mode should be one of these:');
expect(stdout).toBeFalsy();
});
it(`should validate the config with alias 't'`, () => {
const { exitCode, stderr, stdout } = run(__dirname, ['t', './error.config.js'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain('ValidationError: Invalid configuration object.');
expect(stderr).toContain('configuration.mode should be one of these:');
expect(stdout).toBeFalsy();
});
it('should throw error if configuration does not exist', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['configtest', './a.js'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain(`The specified config file doesn't exist`);
expect(stdout).toBeFalsy();
});
it('should throw error if no configuration was provided', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['configtest'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain(`error: missing required argument 'config-path'`);
expect(stdout).toBeFalsy();
});
});