/
basic.test.js
59 lines (46 loc) · 2.23 KB
/
basic.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
'use strict';
const { run } = require('../../utils/test-utils');
describe('bundle command', () => {
it('should work', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['build'], false);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
});
it('should work with the "b" alias', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['b'], false);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
});
it('should work with "bundle" alias', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['bundle'], false);
expect(exitCode).toBe(0);
expect(stderr).toBeFalsy();
expect(stdout).toBeTruthy();
});
it('should log error and suggest right name on the "buil" command', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['buil'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain("Unknown command 'buil'");
expect(stderr).toContain("Did you mean 'build' (alias 'bundle, b')?");
expect(stderr).toContain("Run 'webpack --help' to see available commands and options");
expect(stdout).toBeFalsy();
});
it('should log error with multi commands', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['bundle', 'info'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain('Running multiple commands at the same time is not possible');
expect(stderr).toContain("Found commands: 'build', 'info'");
expect(stderr).toContain("Run 'webpack --help' to see available commands and options");
expect(stdout).toBeFalsy();
});
it('should log error with multi commands', async () => {
const { exitCode, stderr, stdout } = run(__dirname, ['b', 'i'], false);
expect(exitCode).toBe(2);
expect(stderr).toContain('Running multiple commands at the same time is not possible');
expect(stderr).toContain("Found commands: 'build', 'i'");
expect(stderr).toContain("Run 'webpack --help' to see available commands and options");
expect(stdout).toBeFalsy();
});
});