diff --git a/test/cli/fixtures/unhandled-rejection.js b/test/cli/fixtures/unhandled-rejection.js index 82d3b6eed..4846a8925 100644 --- a/test/cli/fixtures/unhandled-rejection.js +++ b/test/cli/fixtures/unhandled-rejection.js @@ -6,19 +6,16 @@ QUnit.module( "Unhandled Rejections", function() { const done = assert.async(); - new Promise( function( resolve ) { - setTimeout( resolve ); - } ) - .then( function() { + Promise.resolve().then( function() { - // 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! + // 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 ); diff --git a/test/reporter-html/unhandled-rejection.js b/test/reporter-html/unhandled-rejection.js index 55c3c66e4..5205e2e8e 100644 --- a/test/reporter-html/unhandled-rejection.js +++ b/test/reporter-html/unhandled-rejection.js @@ -17,12 +17,9 @@ if ( HAS_UNHANDLED_REJECTION_HANDLER ) { QUnit.test( "test passes just fine, but has a rejected promise", function( assert ) { const done = assert.async(); - new Promise( function( resolve ) { - setTimeout( resolve ); - } ) - .then( function() { - throw new Error( "Error thrown in non-returned promise!" ); - } ); + Promise.resolve().then( function() { + throw new Error( "Error thrown in non-returned promise!" ); + } ); // prevent test from exiting before unhandled rejection fires setTimeout( done, 10 );