test: add regression coverage for parse() argv fallback under vite-node - #174
Open
Bryandero98 wants to merge 1 commit into
Open
test: add regression coverage for parse() argv fallback under vite-node#174Bryandero98 wants to merge 1 commit into
Bryandero98 wants to merge 1 commit into
Conversation
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>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/tmpdirectory and against a local checkoutCAC.parse()with no explicit argv correctly resolves to the real CLI args passed after the script name in both casesMy best guess is this was fixed as a side effect of
b943ceb("feat: support on browsers"), which rewrote the oldsrc/node.tsargv-detection logic (since deleted) into the currentsrc/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 plainnodesubprocesses (every fixture inexamples/*.tsis run withnode). There was no coverage for an alternative JS runtime/runner, which is specifically the scenario #158 was about.Adds
vite-nodeas a devDependency and a test that runs the existingbasic-usage.tsfixture throughnpx vite-nodeinstead ofnode, assertingparse()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— cleanpnpm lint— no new warnings/errors introduced🤖 Generated with Claude Code