@@ -19,8 +19,12 @@ import {
19
19
waitFor as dtlWaitFor ,
20
20
waitForElementToBeRemoved as dtlWaitForElementToBeRemoved ,
21
21
screen as dtlScreen ,
22
+ within as dtlWithin ,
22
23
waitForOptions as dtlWaitForOptions ,
23
24
configure as dtlConfigure ,
25
+ Queries ,
26
+ getQueriesForElement ,
27
+ queries as dtlQueries ,
24
28
} from '@testing-library/dom' ;
25
29
import { RenderComponentOptions , RenderDirectiveOptions , RenderTemplateOptions , RenderResult } from './models' ;
26
30
import { getConfig } from './config' ;
@@ -432,6 +436,18 @@ function detectChangesForMountedFixtures() {
432
436
*/
433
437
const screen = replaceFindWithFindAndDetectChanges ( dtlScreen ) ;
434
438
439
+ /**
440
+ * Re-export within with patched queries
441
+ */
442
+
443
+ const within : typeof getQueriesForElement = < T extends Queries = typeof dtlQueries > (
444
+ element : HTMLElement ,
445
+ queriesToBind ?: T ,
446
+ ) => {
447
+ const container = dtlWithin ( element , queriesToBind ) ;
448
+ return replaceFindWithFindAndDetectChanges ( container ) ;
449
+ } ;
450
+
435
451
/**
436
452
* Re-export waitFor with patched waitFor
437
453
*/
@@ -516,8 +532,7 @@ export {
516
532
queryAllByAttribute ,
517
533
queryByAttribute ,
518
534
queryHelpers ,
519
- within ,
520
535
} from '@testing-library/dom' ;
521
536
522
537
// export patched dtl
523
- export { screen , waitFor , waitForElementToBeRemoved } ;
538
+ export { screen , waitFor , waitForElementToBeRemoved , within } ;
0 commit comments