Skip to content

Commit d9171fe

Browse files
committed
assert: fix throws and doesNotThrow stack frames
The stack frames from .throws and .doesNotThrow got included even though that was not intended. PR-URL: #17703 Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 85d5885 commit d9171fe

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
@@ -242,7 +242,7 @@ function innerThrows(shouldThrow, block, expected, message) {
242242
expected,
243243
operator: 'throws',
244244
message: `Missing expected exception${details}`,
245-
stackStartFn: innerThrows
245+
stackStartFn: assert.throws
246246
});
247247
}
248248
if (expected && expectedException(actual, expected) === false) {
@@ -256,7 +256,7 @@ function innerThrows(shouldThrow, block, expected, message) {
256256
expected,
257257
operator: 'doesNotThrow',
258258
message: `Got unwanted exception${details}\n${actual.message}`,
259-
stackStartFn: innerThrows
259+
stackStartFn: assert.doesNotThrow
260260
});
261261
}
262262
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)