@@ -121,7 +121,7 @@ export async function render<SutType, WrapperType = SutType>(
121121 detectChanges ( ) ;
122122 } ;
123123
124- const inject = TestBed . inject || TestBed . get
124+ const inject = TestBed . inject || TestBed . get ;
125125 let router = routes ? inject ( Router ) : null ;
126126 const zone = inject ( NgZone ) ;
127127 const navigate = async ( elementOrPath : Element | string , basePath = '' ) => {
@@ -167,10 +167,7 @@ export async function render<SutType, WrapperType = SutType>(
167167 Array . isArray ( element )
168168 ? element . forEach ( ( e ) => console . log ( dtlPrettyDOM ( e , maxLength , options ) ) )
169169 : console . log ( dtlPrettyDOM ( element , maxLength , options ) ) ,
170- ...replaceFindWithFindAndDetectChanges (
171- fixture . nativeElement ,
172- dtlGetQueriesForElement ( fixture . nativeElement , queries ) ,
173- ) ,
170+ ...replaceFindWithFindAndDetectChanges ( dtlGetQueriesForElement ( fixture . nativeElement , queries ) ) ,
174171 } ;
175172}
176173
@@ -315,10 +312,10 @@ class WrapperComponent {}
315312/**
316313 * Wrap findBy queries to poke the Angular change detection cycle
317314 */
318- function replaceFindWithFindAndDetectChanges < T > ( container : HTMLElement , originalQueriesForContainer : T ) : T {
315+ function replaceFindWithFindAndDetectChanges < T > ( originalQueriesForContainer : T ) : T {
319316 return Object . keys ( originalQueriesForContainer ) . reduce ( ( newQueries , key ) => {
320- if ( key . startsWith ( 'find' ) ) {
321- const getByQuery = originalQueriesForContainer [ key . replace ( 'find' , 'get' ) ] ;
317+ const getByQuery = originalQueriesForContainer [ key . replace ( 'find' , 'get' ) ] ;
318+ if ( key . startsWith ( 'find' ) && getByQuery ) {
322319 newQueries [ key ] = async ( text , options , waitOptions ) => {
323320 // original implementation at https://github.com/testing-library/dom-testing-library/blob/master/src/query-helpers.js
324321 const result = await waitForWrapper (
@@ -354,7 +351,7 @@ function detectChangesForMountedFixtures() {
354351/**
355352 * Re-export screen with patched queries
356353 */
357- const screen = replaceFindWithFindAndDetectChanges ( document . body , dtlScreen ) ;
354+ const screen = replaceFindWithFindAndDetectChanges ( dtlScreen ) ;
358355
359356/**
360357 * Re-export waitFor with patched waitFor
0 commit comments