Skip to content

Commit 24aeca7

Browse files
BridgeARMylesBorins
authored andcommitted
assert: fix throws and doesNotThrow stack frames
The stack frames from .throws and .doesNotThrow got included even though that was not intended. Backport-PR-URL: #19230 PR-URL: #17703 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent db73d1c commit 24aeca7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/assert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ function innerThrows(shouldThrow, block, expected, message) {
245245
expected,
246246
operator: 'throws',
247247
message: `Missing expected exception${details}`,
248-
stackStartFn: innerThrows
248+
stackStartFn: assert.throws
249249
});
250250
}
251251
if (expected && expectedException(actual, expected) === false) {
@@ -259,7 +259,7 @@ function innerThrows(shouldThrow, block, expected, message) {
259259
expected,
260260
operator: 'doesNotThrow',
261261
message: `Got unwanted exception${details}\n${actual.message}`,
262-
stackStartFn: innerThrows
262+
stackStartFn: assert.doesNotThrow
263263
});
264264
}
265265
throw actual;

test/parallel/test-assert.js

+2
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity },
634634
} catch (e) {
635635
threw = true;
636636
assert.strictEqual(e.message, 'Missing expected exception.');
637+
assert.ok(!e.stack.includes('throws'), e.stack);
637638
}
638639
assert.ok(threw);
639640
}
@@ -678,6 +679,7 @@ try {
678679
threw = true;
679680
assert.ok(e.message.includes(rangeError.message));
680681
assert.ok(e instanceof assert.AssertionError);
682+
assert.ok(!e.stack.includes('doesNotThrow'), e.stack);
681683
}
682684
assert.ok(threw);
683685
}

0 commit comments

Comments
 (0)