@ember/test-helpers
Version:
Helpers for testing Ember.js applications
33 lines • 1.24 kB
TypeScript
type ErrorHandlerValidation = Readonly<{
isValid: true;
message: null;
}> | Readonly<{
isValid: false;
message: string;
}>;
/**
* Validate the provided error handler to confirm that it properly re-throws
* errors when `Ember.testing` is true.
*
* This is intended to be used by test framework hosts (or other libraries) to
* ensure that `Ember.onerror` is properly configured. Without a check like
* this, `Ember.onerror` could _easily_ swallow all errors and make it _seem_
* like everything is just fine (and have green tests) when in reality
* everything is on fire...
*
* @public
* @param {Function} [callback=Ember.onerror] the callback to validate
* @returns {Object} object with `isValid` and `message`
*
* @example <caption>Example implementation for `ember-qunit`</caption>
*
* import { validateErrorHandler } from '@ember/test-helpers';
*
* test('Ember.onerror is functioning properly', function(assert) {
* let result = validateErrorHandler();
* assert.ok(result.isValid, result.message);
* });
*/
export default function validateErrorHandler(callback?: ((error: Error) => unknown) | undefined): ErrorHandlerValidation;
export {};
//# sourceMappingURL=validate-error-handler.d.ts.map