diff --git a/lib/test.js b/lib/test.js index 4d6182c0..463e86d0 100644 --- a/lib/test.js +++ b/lib/test.js @@ -257,7 +257,8 @@ Test.prototype._assert = function assert(ok, opts) { this._ok = !!(this._ok && ok); if (!ok && !res.todo) { - res.error = defined(extra.error, opts.error, new Error(res.name)); + var anError = res.name instanceof Error ? res.name : new Error(res.name); + res.error = defined(extra.error, opts.error, anError); } if (!ok) { diff --git a/test/async-await.js b/test/async-await.js index 02aff917..bdc4fc0a 100644 --- a/test/async-await.js +++ b/test/async-await.js @@ -219,7 +219,8 @@ tap.test('async-error', function (t) { ' ---', ' operator: fail', ' stack: |-', - ' Error: Error: oopsie', + ' Error: oopsie', + ' at Test.myTest ($TEST/async-await/async-error.js:$LINE:$COL)', ' [... stack stripped ...]', ' ...', '', diff --git a/test/promise_fail.js b/test/promise_fail.js index ddc93412..eb512bed 100644 --- a/test/promise_fail.js +++ b/test/promise_fail.js @@ -34,7 +34,10 @@ tap.test('callback returning rejected promise should cause that test (and only t ' ---', ' operator: fail', ' stack: |-', - ' Error: Error: rejection message', + ' Error: rejection message', + ' at $TEST/promises/fail.js:$LINE:$COL', + ' [... stack stripped ...]', + ' at Test. ($TEST/promises/fail.js:$LINE:$COL)', ' [... stack stripped ...]', ' ...', '# after', @@ -78,7 +81,10 @@ tap.test('subtest callback returning rejected promise should cause that subtest ' ---', ' operator: fail', ' stack: |-', - ' Error: Error: rejection message', + ' Error: rejection message', + ' at $TEST/promises/subTests.js:$LINE:$COL', + ' [... stack stripped ...]', + ' at Test. ($TEST/promises/subTests.js:$LINE:$COL)', ' [... stack stripped ...]', ' ...', '# sub test that should pass',