command.executableSubcommand.test.js
This file
Path
tests/command.executableSubcommand.test.js
21 lines · 678 bytes · JavaScript
Last changed by
Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
History of this fileTake it
12345678910111213141516171819202122const commander = require('../');
// Executable subcommand tests that didn't fit in elsewhere.
// This is the default behaviour when no default command and no action handlerstest('when no command specified and executable then display help', () => { // Optional. Suppress normal output to keep test output clean. const writeSpy = jest .spyOn(process.stderr, 'write') .mockImplementation(() => {}); const program = new commander.Command(); program .exitOverride((err) => { throw err; }) .command('install', 'install description'); expect(() => { program.parse(['node', 'test']); }).toThrow('(outputHelp)'); writeSpy.mockClear();});