Skip to content

Commit 1672764

Browse files
fix: fallback to TestBed.get (#183)
1 parent 142f7cf commit 1672764

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

projects/testing-library/src/lib/testing-library.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { RenderComponentOptions, RenderDirectiveOptions, RenderResult } from './
2626
import { getConfig } from './config';
2727

2828
const mountedFixtures = new Set<ComponentFixture<any>>();
29+
const inject = TestBed.inject || TestBed.get;
2930

3031
export async function render<ComponentType>(
3132
component: Type<ComponentType>,
@@ -129,7 +130,6 @@ export async function render<SutType, WrapperType = SutType>(
129130
fixture.componentRef.injector.get(ChangeDetectorRef).detectChanges();
130131
};
131132

132-
const inject = TestBed.inject || TestBed.get;
133133
let router = routes ? inject(Router) : null;
134134
const zone = inject(NgZone);
135135
const navigate = async (elementOrPath: Element | string, basePath = '') => {
@@ -185,7 +185,7 @@ export async function render<SutType, WrapperType = SutType>(
185185

186186
async function createComponent<SutType>(component: Type<SutType>): Promise<ComponentFixture<SutType>> {
187187
/* Make sure angular application is initialized before creating component */
188-
await TestBed.inject(ApplicationInitStatus).donePromise;
188+
await inject(ApplicationInitStatus).donePromise;
189189
return TestBed.createComponent(component);
190190
}
191191

0 commit comments

Comments
 (0)