command.unknownOption.test.js
This file
Path
tests/command.unknownOption.test.js
78 lines · 2.2 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–3why, one step back1import { createTestCommand } from './testHelpers.js';2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 4–6why, one step back45// Checking for detection of unknown options, including regression tests for some past issues.6Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 7why, one step back7describe('parsing unknown option', () => {Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 8why, one step back8 test('when specify unknown option with subcommand and action handler then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 9–10why, one step back9 const program = createTestCommand();10 program.command('info').action(() => {});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 11why, one step back11Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 12–17why, one step back12 assert.throws(13 () => {14 program.parse(['node', 'test', 'info', '--NONSENSE']);15 },16 { code: 'commander.unknownOption' },17 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 18–20why, one step back18 });1920 test('when specify unknown option with subcommand argument and action handler then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 21–22why, one step back21 const program = createTestCommand();22 program.command('info <file>').action(() => {});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 23why, one step back23Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 24–29why, one step back24 assert.throws(25 () => {26 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);27 },28 { code: 'commander.unknownOption' },29 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 30–32why, one step back30 });3132 test('when specify unknown option with program and action handler then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 33–34why, one step back33 const program = createTestCommand();34 program.argument('[file]').action(() => {});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 35why, one step back35Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 36–41why, one step back36 assert.throws(37 () => {38 program.parse(['node', 'test', '--NONSENSE']);39 },40 { code: 'commander.unknownOption' },41 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 42–45why, one step back42 });4344 test('when specify unknown option with program argument and action handler then error', () => {45 // Regression test from #965Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 46–47why, one step back46 const program = createTestCommand();47 program.argument('[file]').action(() => {});Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 48why, one step back48Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 49–54why, one step back49 assert.throws(50 () => {51 program.parse(['node', 'test', 'info', 'a', '--NONSENSE']);52 },53 { code: 'commander.unknownOption' },54 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 55–57why, one step back55 });5657 test('when specify unknown option with simple program then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 58–64why, one step back58 const program = createTestCommand();59 assert.throws(60 () => {61 program.parse(['node', 'test', '--NONSENSE']);62 },63 { code: 'commander.unknownOption' },64 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 65–67why, one step back65 });6667 test('when specify unknown global option before subcommand then error', () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 68why, one step back68 const program = createTestCommand();Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 69–70why, one step back69 program.command('sub');70Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 71–76why, one step back71 assert.throws(72 () => {73 program.parse(['--NONSENSE', 'sub'], { from: 'user' });74 },75 { code: 'commander.unknownOption' },76 );Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 77–78why, one step back77 });78});