vitest-dev / vitest-dev/vitest

CLI argument of object form (e.g. `--sequence.no-such-arg`) isn't validated

Open
#9,056 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending triage
Dominant language
TypeScript
Stars
17.1k
Forks
2k
Avg merge
1d 22h
Merged PRs (30d)
94

Description

Describe the bug

When I testing https://github.com/vitest-dev/vitest/pull/9026, I made a typo like vitest --experimental.fsCache (the actual one is --experimental.fsModuleCache) and it took sometime to realize why cache is not working.

It looks like some of other nested form CLI arguments behave similar way:

$ vitest --sequence.no-such-arg

 DEV  v4.0.10 /home/projects/vitest-dev-vitest-uzxirchq

 ✓ test/suite.test.ts (3 tests) 3ms
 ✓ test/basic.test.ts (3 tests) 2ms

 Test Files  2 passed (2)
      Tests  6 passed (6)
   Start at  12:47:30
   Duration  714ms (transform 62ms, setup 0ms, collect 105ms, tests 5ms, environment 0ms, prepare 18ms)

 PASS  Waiting for file changes...
       press h to show help, press q to quit

❯ vitest --sequenceeee.no-such-arg
CACError: Unknown option `--sequenceeee`
    at Command.checkUnknownOptions (file:///home/projects/vitest-dev-vitest-uzxirchq/node_modules/vitest/dist/chunks/cac.
Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-uzxirchq?file=package.json

System Info
System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 4.0.10 
    vite: latest => 7.2.2 
    vitest: latest => 4.0.10
Used Package Manager

npm

Validations

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the behavior with vitest --sequence.no-such-arg and compare it with vitest --sequenceeee.no-such-arg, which already reports an unknown option. Trace the CLI argument parsing and validation for nested options; done means object-form typos are rejected instead of silently accepted, with coverage for the reported examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli, testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.