Skip to content

test: add regression coverage for parse() argv fallback under vite-node - #174

Open
Bryandero98 wants to merge 1 commit into
cacjs:mainfrom
Bryandero98:fix/158-regression-test-runtime-argv
Open

test: add regression coverage for parse() argv fallback under vite-node#174
Bryandero98 wants to merge 1 commit into
cacjs:mainfrom
Bryandero98:fix/158-regression-test-runtime-argv

Conversation

@Bryandero98

Copy link
Copy Markdown

Context

While investigating #158, I could not reproduce the originally reported bug on current main. Verified independently twice:

  • npx vite-node index.ts hello (mirroring the issue's exact repro steps), both in a fresh /tmp directory and against a local checkout
  • CAC.parse() with no explicit argv correctly resolves to the real CLI args passed after the script name in both cases

My best guess is this was fixed as a side effect of b943ceb ("feat: support on browsers"), which rewrote the old src/node.ts argv-detection logic (since deleted) into the current src/runtime.ts, well after #158 was filed.

What this PR does

Rather than claim a fix for something that no longer reproduces, this adds the missing regression coverage: the existing test suite exercises parse()'s no-explicit-argv fallback extensively, but only ever via plain node subprocesses (every fixture in examples/*.ts is run with node). There was no coverage for an alternative JS runtime/runner, which is specifically the scenario #158 was about.

Adds vite-node as a devDependency and a test that runs the existing basic-usage.ts fixture through npx vite-node instead of node, asserting parse() still resolves to the correct args — so a future regression on this path would be caught.

Test plan

  • pnpm test — 18/18 passing (new test included)
  • pnpm typecheck — clean
  • pnpm lint — no new warnings/errors introduced

🤖 Generated with Claude Code

cacjs#158 reported that CAC.parse() with no explicit argv produced wrong
results when the CLI was run via `npx vite-node file.ts ...` instead of
plain `node`. Verified on current main that this no longer reproduces
(most likely fixed as a side effect of b943ceb's rewrite of the old
src/node.ts argv-detection logic into src/runtime.ts), but the existing
suite only ever exercised the no-argv fallback path via plain `node`
subprocesses, so there was no coverage for an alternative JS runtime.
Adds vite-node as a devDependency and a test that runs the same
basic-usage fixture through it, asserting parse() still resolves to
the real CLI args.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant