Skip to content

Commit 8465148

Browse files
authored
test_runner: fix env option validation
Signed-off-by: hanityx <hanityx@gmail.com> PR-URL: #64865 Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
1 parent 2b350bb commit 8465148

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

lib/internal/test_runner/runner.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ function run(options = kEmptyObject) {
910910
}
911911

912912
if (env != null) {
913-
validateObject(env);
913+
validateObject(env, 'options.env');
914914

915915
if (isolation === 'none') {
916916
throw new ERR_INVALID_ARG_VALUE('options.env', env, 'is not supported with isolation=\'none\'');

test/parallel/test-runner-run.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,14 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
673673
}));
674674
});
675675

676+
it('should only allow object in options.env', () => {
677+
[Symbol(), [], () => {}, 0, 1, 0n, 1n, '', '1', true, false]
678+
.forEach((env) => assert.throws(() => run({ files: [], env }), {
679+
code: 'ERR_INVALID_ARG_TYPE',
680+
message: /The "options\.env" property must be of type object\./
681+
}));
682+
});
683+
676684
it('should not allow files and globPatterns used together', () => {
677685
assert.throws(() => run({ files: ['a.js'], globPatterns: ['*.js'] }), {
678686
code: 'ERR_INVALID_ARG_VALUE'

0 commit comments

Comments
 (0)