Skip to content

fix: fallback to TestBed.get #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { RenderComponentOptions, RenderDirectiveOptions, RenderResult } from './
import { getConfig } from './config';

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

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

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

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

Expand Down