/
invalid-schema.test.js
73 lines (55 loc) · 2.67 KB
/
invalid-schema.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
'use strict';
const { run, isWebpack5 } = require('../../utils/test-utils');
describe('invalid schema', () => {
it('should log error on invalid config', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--config', './webpack.config.mock.js']);
expect(exitCode).toEqual(2);
expect(stderr).toContain('Invalid configuration object');
expect(stdout).toBeFalsy();
});
it('should log error on invalid config using the "bundle" command', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--config', './webpack.config.mock.js']);
expect(exitCode).toEqual(2);
expect(stderr).toContain('Invalid configuration object');
expect(stdout).toBeFalsy();
});
it('should log error on invalid config using the "serve" command', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--config', './webpack.config.mock.js']);
expect(exitCode).toEqual(2);
expect(stderr).toContain('Invalid configuration object');
expect(stdout).toBeFalsy();
});
it('should log error on invalid option', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['--mode', 'Yukihira']);
expect(exitCode).toEqual(2);
if (isWebpack5) {
expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option");
expect(stderr).toContain("Expected: 'development | production | none'");
} else {
expect(stderr).toContain('Invalid configuration object');
}
expect(stdout).toBeFalsy();
});
it('should log error on invalid option using "bundle" command', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['bundle', '--mode', 'Yukihira']);
expect(exitCode).toEqual(2);
if (isWebpack5) {
expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option");
expect(stderr).toContain("Expected: 'development | production | none'");
} else {
expect(stderr).toContain('Invalid configuration object');
}
expect(stdout).toBeFalsy();
});
it('should log error on invalid option using "server" command', () => {
const { exitCode, stderr, stdout } = run(__dirname, ['serve', '--mode', 'Yukihira']);
expect(exitCode).toEqual(2);
if (isWebpack5) {
expect(stderr).toContain("Invalid value 'Yukihira' for the '--mode' option");
expect(stderr).toContain("Expected: 'development | production | none'");
} else {
expect(stderr).toContain('Invalid configuration object');
}
expect(stdout).toBeFalsy();
});
});