@@ -19,8 +19,12 @@ import {
1919 waitFor as dtlWaitFor ,
2020 waitForElementToBeRemoved as dtlWaitForElementToBeRemoved ,
2121 screen as dtlScreen ,
22+ within as dtlWithin ,
2223 waitForOptions as dtlWaitForOptions ,
2324 configure as dtlConfigure ,
25+ Queries ,
26+ getQueriesForElement ,
27+ queries as dtlQueries ,
2428} from '@testing-library/dom' ;
2529import { RenderComponentOptions , RenderDirectiveOptions , RenderTemplateOptions , RenderResult } from './models' ;
2630import { getConfig } from './config' ;
@@ -432,6 +436,18 @@ function detectChangesForMountedFixtures() {
432436 */
433437const screen = replaceFindWithFindAndDetectChanges ( dtlScreen ) ;
434438
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+
435451/**
436452 * Re-export waitFor with patched waitFor
437453 */
@@ -516,8 +532,7 @@ export {
516532 queryAllByAttribute ,
517533 queryByAttribute ,
518534 queryHelpers ,
519- within ,
520535} from '@testing-library/dom' ;
521536
522537// export patched dtl
523- export { screen , waitFor , waitForElementToBeRemoved } ;
538+ export { screen , waitFor , waitForElementToBeRemoved , within } ;
0 commit comments