From 0bd8a06fd06752cca3e7cb4f0b84153f9ebbf4c6 Mon Sep 17 00:00:00 2001 From: timdeschryver <28659384+timdeschryver@users.noreply.github.com> Date: Thu, 23 Jul 2020 09:47:26 +0200 Subject: [PATCH] fix: fallfback to TestBed.get if inject doesn't exist --- projects/testing-library/src/lib/testing-library.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/projects/testing-library/src/lib/testing-library.ts b/projects/testing-library/src/lib/testing-library.ts index 9f0d5c9c..49959af0 100644 --- a/projects/testing-library/src/lib/testing-library.ts +++ b/projects/testing-library/src/lib/testing-library.ts @@ -121,11 +121,12 @@ export async function render( detectChanges(); }; - let router = routes ? TestBed.inject(Router) : null; - const zone = TestBed.inject(NgZone); + const inject = TestBed.inject || TestBed.get + let router = routes ? inject(Router) : null; + const zone = inject(NgZone); const navigate = async (elementOrPath: Element | string, basePath = '') => { if (!router) { - router = TestBed.inject(Router); + router = inject(Router); } const href = typeof elementOrPath === 'string' ? elementOrPath : elementOrPath.getAttribute('href');