Skip to content
Myr

command.executableSubcommand.test.js

This file

Path

tests/command.executableSubcommand.test.js

17 lines · 659 bytes · JavaScript

Last changed by

Expand help customisation with .addHelpText (#1296)John Geebefore adoptiond26a26d

History of this file

Take it

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 1–5why, one step back
1const commander = require('../');
23// Executable subcommand tests that didn't fit in elsewhere.45// This is the default behaviour when no default command and no action handlers

Expand help customisation with .addHelpText (#1296)John Geebefore adoptiond26a26d

line 6why, one step back
6test('when no command specified and executable then display help', () => {

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

line 7why, one step back
7 // Optional. Suppress normal output to keep test output clean.

Expand help customisation with .addHelpText (#1296)John Geebefore adoptiond26a26d

line 8why, one step back
8 const writeSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => { });

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 9–10why, one step back
9 const program = new commander.Command();
10 program

Add override to allow throw instead of process.exit (#1040)John Geebefore adoption8df692e

line 11why, one step back
11 .exitOverride((err) => { throw err; })

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 12–17why, one step back
12 .command('install', 'install description');
13 expect(() => {14 program.parse(['node', 'test']);15 }).toThrow('(outputHelp)');16 writeSpy.mockClear();17});