Skip to content

Commit 4c7bb37

Browse files
committed
test_runner: fix empty object test assert logic
This change updates the test 'test-runner-xfail.js' so that the validation of empty object exceptions correctly uses assert.throws() with the required two arguments and checks for the 'ok' test status in the output instead of checking for a console log of the caught exception.
1 parent 429ac6e commit 4c7bb37

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/parallel/test-runner-xfail.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,10 @@ if (process.env.CHILD_PROCESS === 'true') {
108108
});
109109

110110
// 6. Edge Case: Empty Object (Should throw ERR_INVALID_ARG_VALUE during creation)
111-
try {
112-
test('invalid empty object', { expectFailure: {} }, () => {});
113-
} catch (e) {
114-
console.log(`CAUGHT_INVALID_ARG: ${e.code}`);
115-
}
111+
test('invalid empty object throws', () => {
112+
// eslint-disable-next-line no-restricted-syntax
113+
assert.throws(() => test('invalid empty object', { expectFailure: {} }, () => {}));
114+
});
116115

117116
// 7. Primitives and Truthiness
118117
test('fails with boolean true', { expectFailure: true }, () => {
@@ -251,7 +250,7 @@ if (process.env.CHILD_PROCESS === 'true') {
251250
assert.match(stdout, /ok \d+ - suite subtest match suite expectation # EXPECTED FAILURE/);
252251

253252
// Empty object error
254-
assert.match(stdout, /CAUGHT_INVALID_ARG: ERR_INVALID_ARG_VALUE/);
253+
assert.match(stdout, /ok \d+ - invalid empty object throws/);
255254
assert.match(stdout, /ok \d+ - correct config with label and match object # EXPECTED FAILURE Bug \\#124/);
256255
assert.match(stdout, /not ok \d+ - fails with ambiguous config \(mixed props\) # EXPECTED FAILURE/);
257256
assert.match(stdout, /not ok \d+ - fails with ambiguous config \(mixed props with match\) # EXPECTED FAILURE/);

0 commit comments

Comments
 (0)