diff --git a/test/cli/fixtures/expected/tap-outputs.js b/test/cli/fixtures/expected/tap-outputs.js index f0ad51c9b..031a442b9 100644 --- a/test/cli/fixtures/expected/tap-outputs.js +++ b/test/cli/fixtures/expected/tap-outputs.js @@ -1,3 +1,7 @@ +"use strict"; + +const path = require( "path" ); + // Expected outputs from the TapReporter for the commands run in CLI tests module.exports = { "qunit": @@ -97,21 +101,25 @@ not ok 1 Unhandled Rejections > test passes just fine, but has a rejected promis --- message: "Error thrown in non-returned promise!" severity: failed - actual: {} + actual: { + "message": "Error thrown in non-returned promise!", + "stack": "Error: Error thrown in non-returned promise!\\n at /some/path/wherever/unhandled-rejection.js:13:11" +} expected: undefined stack: Error: Error thrown in non-returned promise! - at /Users/rjackson/src/open-source/qunit/test/cli/fixtures/unhandled-rejection.js:13:11 - at + at /some/path/wherever/unhandled-rejection.js:13:11 ... not ok 2 global failure --- message: "outside of a test context" severity: failed actual: { - "message": "outside of a test context" + "message": "outside of a test context", + "stack": "Error: outside of a test context\\n at Object. (/some/path/wherever/unhandled-rejection.js:20:18)" } expected: undefined - stack: at runTest (/Users/rjackson/src/open-source/qunit/dist/qunit.js:1478:30) + stack: Error: outside of a test context + at Object. (/some/path/wherever/unhandled-rejection.js:20:18) ... 1..2 # pass 0 diff --git a/test/cli/fixtures/unhandled-rejection.js b/test/cli/fixtures/unhandled-rejection.js index 9f3eea81c..82d3b6eed 100644 --- a/test/cli/fixtures/unhandled-rejection.js +++ b/test/cli/fixtures/unhandled-rejection.js @@ -10,12 +10,25 @@ QUnit.module( "Unhandled Rejections", function() { setTimeout( resolve ); } ) .then( function() { - throw new Error( "Error thrown in non-returned promise!" ); + + // throwing a non-Error here because stack trace representation + // across Node versions is not stable (they continue to get better) + throw { + message: "Error thrown in non-returned promise!", + stack: `Error: Error thrown in non-returned promise! + at /some/path/wherever/unhandled-rejection.js:13:11` + }; } ); // prevent test from exiting before unhandled rejection fires setTimeout( done, 10 ); } ); - Promise.reject( { message: "outside of a test context" } ); + // rejecting with a non-Error here because stack trace representation + // across Node versions is not stable (they continue to get better) + Promise.reject( { + message: "outside of a test context", + stack: `Error: outside of a test context + at Object. (/some/path/wherever/unhandled-rejection.js:20:18)` + } ); } );