command.executableSubcommand.test.js
This file
Path
tests/command.executableSubcommand.test.js
17 lines · 659 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
123456789101112131415161718const 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();});