<commit_before>const commander = require('../');

// Checking for detection of unknown options, including regression tests for some past issues.

describe('unknownOption', () => {
  // Optional. Use internal knowledge to suppress output to keep test output clean.
  let writeErrorSpy;

  beforeAll(() => {
    writeErrorSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => { });
  });

  afterEach(() => {
    writeErrorSpy.mockClear();
  });

  afterAll(() => {
    writeErrorSpy.mockRestore();
  });

  test('when specify unknown option with subcommand and action handler then error', () => {
    const program = new commander.Command();
    program
      .exitOverride()
      .command('info')
      .action(() => {});

    let caughtErr;
    try {
      program.parse(['node', 'info', '--NONSENSE']);
    } catch (err) {
      caughtErr = err;
    }<commit_msg>Missing subcommand in action for test (#1462)<commit_after>const commander = require('../');

// Checking for detection of unknown options, including regression tests for some past issues.

describe('unknownOption', () => {
  // Optional. Use internal knowledge to suppress output to keep test output clean.
  let writeErrorSpy;

  beforeAll(() => {
    writeErrorSpy = jest.spyOn(process.stderr, 'write').mockImplementation(() => { });
  });

  afterEach(() => {
    writeErrorSpy.mockClear();
  });

  afterAll(() => {
    writeErrorSpy.mockRestore();
  });

  test('when specify unknown option with subcommand and action handler then error', () => {
    const program = new commander.Command();
    program
      .exitOverride()
      .command('info')
      .action(() => {});

    let caughtErr;
    try {
      program.parse(['node', 'test', 'info', '--NONSENSE']);
    } catch (err) {
      caughtErr = err;
    }
{'fraction_non_alphanumeric': 0.15906562847608455, 'fraction_numerical': 0.002224694104560623, 'mean_word_length': 3.203271028037383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5198782', 'n_tokens_mistral': 523, 'n_tokens_neox': 505, 'n_words': 143}