-
Notifications
You must be signed in to change notification settings - Fork 781
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test: Convert reporter-html/unhandled-rejection.js to main/ test
- Loading branch information
Showing
9 changed files
with
45 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
QUnit.module('browser-runner', function () { | ||
/* global window, Promise, setTimeout */ | ||
var HAS_UNHANDLED_REJECTION_HANDLER = (typeof window !== 'undefined' && 'onunhandledrejection' in window && typeof Promise === 'function'); | ||
|
||
// Skip in non-browser and unsupporting browsers | ||
QUnit.module.if('onunhandledrejection', HAS_UNHANDLED_REJECTION_HANDLER, function (hooks) { | ||
// TODO: Once we run browser tests with QTap, remove this hack | ||
// and instead write expected failures in .tap.txt snapshots. | ||
hooks.beforeEach(function (assert) { | ||
var test = this; | ||
var original = assert.pushResult; | ||
assert.pushResult = function (resultInfo) { | ||
if (test.expectedFailure && test.expectedFailure === resultInfo.message) { | ||
// Restore | ||
assert.pushResult = original; | ||
test.expectedFailure = null; | ||
// Inverts the result of the (one) expected failure | ||
resultInfo.result = !resultInfo.result; | ||
} | ||
|
||
return original.call(assert, resultInfo); | ||
}; | ||
}); | ||
|
||
QUnit.test('example', function (assert) { | ||
var done = assert.async(); | ||
|
||
this.expectedFailure = 'global failure: Error: Error thrown in non-returned promise!'; | ||
|
||
// eslint-disable-next-line compat/compat -- Checked | ||
Promise.resolve().then(function () { | ||
// prevent test from exiting before unhandled rejection fires | ||
setTimeout(done, 20); | ||
throw new Error('Error thrown in non-returned promise!'); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters