UNPKG

1.24 kBTypeScriptView Raw
1type ErrorHandlerValidation = Readonly<{
2 isValid: true;
3 message: null;
4}> | Readonly<{
5 isValid: false;
6 message: string;
7}>;
8/**
9 * Validate the provided error handler to confirm that it properly re-throws
10 * errors when `Ember.testing` is true.
11 *
12 * This is intended to be used by test framework hosts (or other libraries) to
13 * ensure that `Ember.onerror` is properly configured. Without a check like
14 * this, `Ember.onerror` could _easily_ swallow all errors and make it _seem_
15 * like everything is just fine (and have green tests) when in reality
16 * everything is on fire...
17 *
18 * @public
19 * @param {Function} [callback=Ember.onerror] the callback to validate
20 * @returns {Object} object with `isValid` and `message`
21 *
22 * @example <caption>Example implementation for `ember-qunit`</caption>
23 *
24 * import { validateErrorHandler } from '@ember/test-helpers';
25 *
26 * test('Ember.onerror is functioning properly', function(assert) {
27 * let result = validateErrorHandler();
28 * assert.ok(result.isValid, result.message);
29 * });
30 */
31export default function validateErrorHandler(callback?: ((error: Error) => unknown) | undefined): ErrorHandlerValidation;
32export {};
33//# sourceMappingURL=validate-error-handler.d.ts.map
\No newline at end of file