command.helpOption.test.js
This file
Path
tests/command.helpOption.test.js
22 lines · 871 bytes · JavaScript
Last changed by
Add override to allow throw instead of process.exit (#1040)John Geebefore adoption8df692e
History of this fileTake it
Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 1–7why, one step back1const commander = require('../');23test('when helpOption has custom flags then custom flag invokes help', () => {4 // Optional. Suppress normal output to keep test output clean.5 const writeSpy = jest.spyOn(process.stdout, 'write').mockImplementation(() => { });6 const program = new commander.Command();7 programAdd override to allow throw instead of process.exit (#1040)John Geebefore adoption8df692e
line 8why, one step back8 .exitOverride()Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 9–22why, one step back9 .helpOption('--custom-help', 'custom help output');10 expect(() => {11 program.parse(['node', 'test', '--custom-help']);12 }).toThrow('(outputHelp)');13 writeSpy.mockClear();14});1516test('when helpOption has custom description then helpInformation include custom description', () => {17 const program = new commander.Command();18 program19 .helpOption('-C,--custom-help', 'custom help output');20 const helpInformation = program.helpInformation();21 expect(helpInformation).toMatch(/-C,--custom-help +custom help output/);22});