fix(ivy): rethrow event handler errors in tests (#28707)
Currently errors thrown inside event handler in Ivy are caught and forwarded to the `ErrorHandler`, however this means that if they happen during a unit test, the test won't fail. These changes add a test-specific `ErrorHandler` that throws the error rather than logging it out. PR Close #28707
This commit is contained in:
parent
83fd66d1d0
commit
63e5d2787b
|
@ -15,6 +15,7 @@ import {
|
||||||
Compiler,
|
Compiler,
|
||||||
Component,
|
Component,
|
||||||
Directive,
|
Directive,
|
||||||
|
ErrorHandler,
|
||||||
Injector,
|
Injector,
|
||||||
ModuleWithComponentFactories,
|
ModuleWithComponentFactories,
|
||||||
NgModule,
|
NgModule,
|
||||||
|
@ -600,6 +601,7 @@ export class TestBedRender3 implements Injector, TestBed {
|
||||||
const providers = [
|
const providers = [
|
||||||
{provide: NgZone, useValue: ngZone},
|
{provide: NgZone, useValue: ngZone},
|
||||||
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
|
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
|
||||||
|
{provide: ErrorHandler, useClass: R3TestErrorHandler},
|
||||||
...this._providers,
|
...this._providers,
|
||||||
...this._providerOverrides,
|
...this._providerOverrides,
|
||||||
];
|
];
|
||||||
|
@ -813,3 +815,8 @@ class R3TestCompiler implements Compiler {
|
||||||
return meta && meta.id || undefined;
|
return meta && meta.id || undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Error handler used for tests. Rethrows errors rather than logging them out. */
|
||||||
|
class R3TestErrorHandler extends ErrorHandler {
|
||||||
|
handleError(error: any) { throw error; }
|
||||||
|
}
|
||||||
|
|
|
@ -985,6 +985,10 @@ window.testBlocklist = {
|
||||||
"error": "Error: Expected mat-slide-toggle-thumb-container to contain 'mat-dragging'.",
|
"error": "Error: Expected mat-slide-toggle-thumb-container to contain 'mat-dragging'.",
|
||||||
"notes": "Unknown"
|
"notes": "Unknown"
|
||||||
},
|
},
|
||||||
|
"MatSlideToggle without forms custom action configuration should not change value on click when click action is noop": {
|
||||||
|
"error": "TypeError: this._inputElement is undefined",
|
||||||
|
"notes": "Unknown"
|
||||||
|
},
|
||||||
"MatDrawer methods should be able to open": {
|
"MatDrawer methods should be able to open": {
|
||||||
"error": "Error: Expected 0 to be 1.",
|
"error": "Error: Expected 0 to be 1.",
|
||||||
"notes": "Unknown"
|
"notes": "Unknown"
|
||||||
|
|
Loading…
Reference in New Issue