From c5b81743c5bc8dc4c02c7d0530b73e104623be18 Mon Sep 17 00:00:00 2001 From: Renegade334 Date: Tue, 16 Dec 2025 19:39:40 +0000 Subject: [PATCH] test: check util.parseArgs argv parsing with actual process execution --- test/fixtures/parse-args.js | 5 +++++ test/parallel/test-parse-args.mjs | 29 ++++++++++------------------- 2 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 test/fixtures/parse-args.js diff --git a/test/fixtures/parse-args.js b/test/fixtures/parse-args.js new file mode 100644 index 00000000000000..104cabbf679e8a --- /dev/null +++ b/test/fixtures/parse-args.js @@ -0,0 +1,5 @@ +const { parseArgs } = require('util'); + +const parsedArgs = parseArgs({ strict: false }).values; + +process.stdout.write(JSON.stringify(parsedArgs)); diff --git a/test/parallel/test-parse-args.mjs b/test/parallel/test-parse-args.mjs index 23d55ff4d899cc..665ec357c95fbc 100644 --- a/test/parallel/test-parse-args.mjs +++ b/test/parallel/test-parse-args.mjs @@ -1,4 +1,5 @@ import { spawnPromisified } from '../common/index.mjs'; +import { path } from '../common/fixtures.mjs'; import assert from 'node:assert'; import { suite, test } from 'node:test'; import { parseArgs } from 'node:util'; @@ -212,6 +213,8 @@ test('order of option and positional does not matter (per README)', () => { }); suite('correct default args', () => { + const expected = { code: 0, signal: null, stderr: '', stdout: { foo: true, bar: true } }; + suite('with CLI flags', () => { const evalCode = "JSON.stringify(require('util').parseArgs({ strict: false }).values)"; const evalCodePrinted = `process.stdout.write(${evalCode})`; @@ -225,33 +228,21 @@ suite('correct default args', () => { '--print --eval