nodejs / nodejs/node

Using `--test` causes process.argv[] to lose user-specified CLI flags

Đang mở
#61,852 5 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Ngôn ngữ chính
JavaScript
Star
122k
Fork
37.4k
Merge trung bình
4 ngày 3 giờ
Pull request đã merge (30 ngày)
272

Mô tả

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 -- --hello or node --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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với bản tái hiện trong foo.js và so sánh process.argv khi chạy node foo.js --hello với node --test foo.js --hello. Truy vết cách node:test xử lý các đối số của script, sau đó thêm một bài kiểm thử hồi quy cho thấy --hello vẫn nằm trong process.argv và chạy các bài kiểm thử test-runner liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
javascript, node.js
Lĩnh vực
testing
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
58/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.