Skip to content

Commit 3bebcf0

Browse files
BridgeARaddaleax
authored andcommitted
test: fix failing assertion
One test did not cause an assertion. By changing the test to use `assert.throws()` all tests have to throw, otherwise the test will fail. PR-URL: #25250 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent e09dd0c commit 3bebcf0

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

test/parallel/test-assert.js

+9-11
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,14 @@ const circular = { y: 1 };
257257
circular.x = circular;
258258

259259
function testAssertionMessage(actual, expected, msg) {
260-
try {
261-
assert.strictEqual(actual, '');
262-
} catch (e) {
263-
assert.strictEqual(
264-
e.message,
265-
msg || strictEqualMessageStart +
266-
`+ actual - expected\n\n+ ${expected}\n- ''`
267-
);
268-
assert.ok(e.generatedMessage, 'Message not marked as generated');
269-
}
260+
assert.throws(
261+
() => assert.strictEqual(actual, ''),
262+
{
263+
generatedMessage: true,
264+
message: msg || strictEqualMessageStart +
265+
`+ actual - expected\n\n+ ${expected}\n- ''`
266+
}
267+
);
270268
}
271269

272270
function testShortAssertionMessage(actual, expected) {
@@ -280,7 +278,7 @@ testShortAssertionMessage(false, 'false');
280278
testShortAssertionMessage(100, '100');
281279
testShortAssertionMessage(NaN, 'NaN');
282280
testShortAssertionMessage(Infinity, 'Infinity');
283-
testShortAssertionMessage('', '""');
281+
testShortAssertionMessage('a', '"a"');
284282
testShortAssertionMessage('foo', '\'foo\'');
285283
testShortAssertionMessage(0, '0');
286284
testShortAssertionMessage(Symbol(), 'Symbol()');

0 commit comments

Comments
 (0)