fix(ivy): TestBed overriding custom ErrorHandler (#29482)
Fixes TestBed's default ErrorHandler overriding the one provided by the consumer via an `import`. This PR resolves FW-1193. PR Close #29482
This commit is contained in:

committed by
Miško Hevery

parent
b5295ad277
commit
bef5043a5a
@ -630,17 +630,22 @@ export class TestBedRender3 implements Injector, TestBed {
|
||||
class RootScopeModule {
|
||||
}
|
||||
|
||||
@NgModule({providers: [{provide: ErrorHandler, useClass: R3TestErrorHandler}]})
|
||||
class R3ErrorHandlerModule {
|
||||
}
|
||||
|
||||
const ngZone = new NgZone({enableLongStackTrace: true});
|
||||
const providers = [
|
||||
{provide: NgZone, useValue: ngZone},
|
||||
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
|
||||
{provide: ErrorHandler, useClass: R3TestErrorHandler},
|
||||
...this._providers,
|
||||
...this._providerOverrides,
|
||||
];
|
||||
|
||||
// We need to provide the `R3ErrorHandlerModule` after the consumer's NgModule so that we can
|
||||
// override the default ErrorHandler, if the consumer didn't pass in a custom one.
|
||||
const imports = [RootScopeModule, this.ngModule, R3ErrorHandlerModule, this._imports];
|
||||
const declarations = this._declarations;
|
||||
const imports = [RootScopeModule, this.ngModule, this._imports];
|
||||
const schemas = this._schemas;
|
||||
|
||||
@NgModule({providers, declarations, imports, schemas, jit: true})
|
||||
|
Reference in New Issue
Block a user