@@ -121,7 +121,7 @@ export async function render<SutType, WrapperType = SutType>(
121
121
detectChanges ( ) ;
122
122
} ;
123
123
124
- const inject = TestBed . inject || TestBed . get
124
+ const inject = TestBed . inject || TestBed . get ;
125
125
let router = routes ? inject ( Router ) : null ;
126
126
const zone = inject ( NgZone ) ;
127
127
const navigate = async ( elementOrPath : Element | string , basePath = '' ) => {
@@ -167,10 +167,7 @@ export async function render<SutType, WrapperType = SutType>(
167
167
Array . isArray ( element )
168
168
? element . forEach ( ( e ) => console . log ( dtlPrettyDOM ( e , maxLength , options ) ) )
169
169
: console . log ( dtlPrettyDOM ( element , maxLength , options ) ) ,
170
- ...replaceFindWithFindAndDetectChanges (
171
- fixture . nativeElement ,
172
- dtlGetQueriesForElement ( fixture . nativeElement , queries ) ,
173
- ) ,
170
+ ...replaceFindWithFindAndDetectChanges ( dtlGetQueriesForElement ( fixture . nativeElement , queries ) ) ,
174
171
} ;
175
172
}
176
173
@@ -315,10 +312,10 @@ class WrapperComponent {}
315
312
/**
316
313
* Wrap findBy queries to poke the Angular change detection cycle
317
314
*/
318
- function replaceFindWithFindAndDetectChanges < T > ( container : HTMLElement , originalQueriesForContainer : T ) : T {
315
+ function replaceFindWithFindAndDetectChanges < T > ( originalQueriesForContainer : T ) : T {
319
316
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 ) {
322
319
newQueries [ key ] = async ( text , options , waitOptions ) => {
323
320
// original implementation at https://github.com/testing-library/dom-testing-library/blob/master/src/query-helpers.js
324
321
const result = await waitForWrapper (
@@ -354,7 +351,7 @@ function detectChangesForMountedFixtures() {
354
351
/**
355
352
* Re-export screen with patched queries
356
353
*/
357
- const screen = replaceFindWithFindAndDetectChanges ( document . body , dtlScreen ) ;
354
+ const screen = replaceFindWithFindAndDetectChanges ( dtlScreen ) ;
358
355
359
356
/**
360
357
* Re-export waitFor with patched waitFor
0 commit comments