/
help-commands.test.js
29 lines (24 loc) · 1.18 KB
/
help-commands.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
'use strict';
const { run } = require('../utils/test-utils');
const helpHeader = 'The build tool for modern web applications';
describe('commands help', () => {
it('shows help information with subcommands as an arg', () => {
const { stdout, stderr } = run(__dirname, ['help', 'serve'], false);
expect(stdout).toContain('webpack s | serve');
expect(stderr).toHaveLength(0);
});
it('throws error for invalid command with --help flag', () => {
const { stderr } = run(__dirname, ['--help', 'myCommand'], false);
expect(stderr).toContain(`You provided an invalid command 'myCommand'`);
});
it('throws error for invalid command with help command', () => {
const { stderr } = run(__dirname, ['help', 'myCommand'], false);
expect(stderr).toContain(`You provided an invalid command 'myCommand'`);
});
it('gives precedence to earlier command in case of multiple commands', () => {
const { stdout, stderr } = run(__dirname, ['--help', 'init', 'info'], false);
expect(stdout).not.toContain(helpHeader);
expect(stdout).toContain('webpack c | init [scaffold]');
expect(stderr).toHaveLength(0);
});
});