Skip to content

Commit

Permalink
[New] when the error type is wrong, show the message and stack
Browse files Browse the repository at this point in the history
Fixes #479.
  • Loading branch information
ljharb committed Jul 29, 2019
1 parent 44cbbf5 commit c283615
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 0 additions & 1 deletion lib/test.js
Expand Up @@ -509,7 +509,6 @@ Test.prototype['throws'] = function (fn, expected, msg, extra) {

if (typeof expected === 'function' && caught) {
passed = caught.error instanceof expected;
caught.error = caught.error.constructor;
}

this._assert(typeof fn === 'function' && passed, {
Expand Down
6 changes: 5 additions & 1 deletion test/throws.js
Expand Up @@ -171,8 +171,12 @@ tap.test('failures', function (tt) {
+ ' expected: |-\n'
+ ' [Function: TypeError]\n'
+ ' actual: |-\n'
+ ' [Function: RangeError]\n'
+ " { [RangeError: actual!] message: 'actual!' }\n"
+ ' at: Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' stack: |-\n'
+ ' RangeError: actual!\n'
+ ' at Test.<anonymous> ($TEST/throws.js:$LINE:$COL)\n'
+ ' [... stack stripped ...]\n'
+ ' ...\n'
+ '\n1..14\n'
+ '# tests 14\n'
Expand Down

0 comments on commit c283615

Please sign in to comment.