Using `--test` causes process.argv[] to lose user-specified CLI flags
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.4k
- Merge medio
- 4g 3h
- PR unite (30g)
- 272
Descrizione
Version
v25.6.1
Platform
Darwin MacBookPro.lan 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 17 21:41:45 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6000 arm64
Subsystem
node:test
What steps will reproduce the bug?
Create a file, "foo.js":
console.log(process.argv);
... then invoke node with a custom CLI flag (--hello), and both with and without the --test flag:
# Run script with a custom CLI flag (without --test):
$ node foo.js --hello
[
'/Users/kieffer/.nvm/versions/node/v25.6.1/bin/node',
'/Users/kieffer/codepen/codewatch/packages/foo.js',
'--hello'
]
# ... now add `--test`:
$ node --test foo.js --hello
[
'/Users/kieffer/.nvm/versions/node/v25.6.1/bin/node',
'/Users/kieffer/codepen/codewatch/packages/foo.js'
]
✔ foo.js (35.9505ms)
<snip>
[!NOTE]
Running with the "--" flag (e.g.node foo.js -- --helloornode --test foo.js -- --hello) yields the same behavior.
How often does it reproduce? Is there a required condition?
Consistent.
What is the expected behavior? Why is that the expected behavior?
process.argv should include the user-provided CLI flag in both cases.
What do you see instead?
When running with --test, process.argv omits the user-supplied --hello flag.
This makes testing code that depends on process.argv problematic, obviously.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con la riproduzione in foo.js e confronta process.argv eseguendo node foo.js --hello e node --test foo.js --hello. Traccia il modo in cui node:test gestisce gli argomenti dello script, quindi aggiungi un test di regressione che mostri che --hello rimane in process.argv ed esegui i test pertinenti del test-runner.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- testing
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 58/100