Skip to content

Commit 0510930

Browse files
atscottAndrewKushnir
authored andcommitted
fix(core): TestBed should not override NgZone from initTestEnvironment (angular#55226)
Prior to this change, `NgZone` was provided by default in TestBed in a location that would override anything configured in `TestBed.initTestEnvironment`. This change moves the default `NgZone` provider to the `RootScopeModule` and these providers can be overridden by the ones in `additionalModuleTypes`, which are assigned from the first argument of `initTestEnvironment`. This makes it possible to configure Zone globally for all tests as opposed to needing to repeat it in `configureTestingModule` of each suite. PR Close angular#55226
1 parent a040fb7 commit 0510930

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

packages/core/testing/src/test_bed_compiler.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -927,11 +927,10 @@ export class TestBedCompiler {
927927
private compileTestModule(): void {
928928
class RootScopeModule {}
929929
compileNgModuleDefs(RootScopeModule as NgModuleType<any>, {
930-
providers: [...this.rootProviderOverrides],
930+
providers: [...this.rootProviderOverrides, provideZoneChangeDetection()],
931931
});
932932

933933
const providers = [
934-
provideZoneChangeDetection(),
935934
{provide: Compiler, useFactory: () => new R3TestCompiler(this)},
936935
{provide: DEFER_BLOCK_CONFIG, useValue: {behavior: this.deferBlockBehavior}},
937936
...this.providers,

0 commit comments

Comments
 (0)