diff --git a/lib/assert.js b/lib/assert.js index aca8313a09cbfe..00542b53fc8c87 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -242,7 +242,7 @@ function innerThrows(shouldThrow, block, expected, message) { expected, operator: 'throws', message: `Missing expected exception${details}`, - stackStartFn: innerThrows + stackStartFn: assert.throws }); } if (expected && expectedException(actual, expected) === false) { @@ -256,7 +256,7 @@ function innerThrows(shouldThrow, block, expected, message) { expected, operator: 'doesNotThrow', message: `Got unwanted exception${details}\n${actual.message}`, - stackStartFn: innerThrows + stackStartFn: assert.doesNotThrow }); } throw actual; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index b64c777bddee9a..6c3aced7b669dc 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -634,6 +634,7 @@ testAssertionMessage({ a: NaN, b: Infinity, c: -Infinity }, } catch (e) { threw = true; assert.strictEqual(e.message, 'Missing expected exception.'); + assert.ok(!e.stack.includes('throws'), e.stack); } assert.ok(threw); } @@ -678,6 +679,7 @@ try { threw = true; assert.ok(e.message.includes(rangeError.message)); assert.ok(e instanceof assert.AssertionError); + assert.ok(!e.stack.includes('doesNotThrow'), e.stack); } assert.ok(threw); }