@@ -12,8 +12,8 @@ import { Component, EventEmitter, Type } from '@angular/core'
12
12
import {
13
13
ComponentFixture ,
14
14
getTestBed ,
15
- TestBed ,
16
15
TestModuleMetadata ,
16
+ TestBed ,
17
17
} from '@angular/core/testing'
18
18
import {
19
19
BrowserDynamicTestingModule ,
@@ -144,12 +144,12 @@ function initTestBed<T> (
144
144
145
145
const componentFixture = createComponentFixture ( component ) as Type < T >
146
146
147
- TestBed . configureTestingModule ( {
147
+ getTestBed ( ) . configureTestingModule ( {
148
148
...bootstrapModule ( componentFixture , configRest ) ,
149
149
} )
150
150
151
151
if ( providers != null ) {
152
- TestBed . overrideComponent ( componentFixture , {
152
+ getTestBed ( ) . overrideComponent ( componentFixture , {
153
153
add : {
154
154
providers,
155
155
} ,
@@ -172,6 +172,8 @@ function createComponentFixture<T> (
172
172
component : Type < T > | string ,
173
173
) : Type < T | WrapperComponent > {
174
174
if ( typeof component === 'string' ) {
175
+ // getTestBed().overrideTemplate is available in v14+
176
+ // The static TestBed.overrideTemplate is available across versions
175
177
TestBed . overrideTemplate ( WrapperComponent , component )
176
178
177
179
return WrapperComponent
@@ -192,7 +194,7 @@ function setupFixture<T> (
192
194
component : Type < T > ,
193
195
config : MountConfig < T > ,
194
196
) : ComponentFixture < T > {
195
- const fixture = TestBed . createComponent ( component )
197
+ const fixture = getTestBed ( ) . createComponent ( component )
196
198
197
199
fixture . whenStable ( ) . then ( ( ) => {
198
200
fixture . autoDetectChanges ( config . autoDetectChanges ?? true )
@@ -309,6 +311,6 @@ getTestBed().initTestEnvironment(
309
311
310
312
setupHooks ( ( ) => {
311
313
// Not public, we need to call this to remove the last component from the DOM
312
- TestBed [ 'tearDownTestingModule' ] ( )
313
- TestBed . resetTestingModule ( )
314
+ getTestBed ( ) [ 'tearDownTestingModule' ] ( )
315
+ getTestBed ( ) . resetTestingModule ( )
314
316
} )
0 commit comments