Skip to content

Commit 2c6abad

Browse files
committed
fix: patch findby to invoke a cd cycle
1 parent 53a67d7 commit 2c6abad

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

projects/testing-library/src/lib/testing-library.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ 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+
getQueriesForElement,
26+
Queries,
2427
} from '@testing-library/dom';
2528
import { RenderComponentOptions, RenderDirectiveOptions, RenderTemplateOptions, RenderResult } from './models';
2629
import { getConfig } from './config';
@@ -432,6 +435,14 @@ function detectChangesForMountedFixtures() {
432435
*/
433436
const screen = replaceFindWithFindAndDetectChanges(dtlScreen);
434437

438+
/**
439+
* Re-export within with patched queries
440+
*/
441+
function within(element: HTMLElement, queriesToBind?: Queries) {
442+
const container = dtlWithin(element, queriesToBind);
443+
return replaceFindWithFindAndDetectChanges(container);
444+
}
445+
435446
/**
436447
* Re-export waitFor with patched waitFor
437448
*/
@@ -516,8 +527,7 @@ export {
516527
queryAllByAttribute,
517528
queryByAttribute,
518529
queryHelpers,
519-
within,
520530
} from '@testing-library/dom';
521531

522532
// export patched dtl
523-
export { screen, waitFor, waitForElementToBeRemoved };
533+
export { screen, waitFor, waitForElementToBeRemoved, within };

0 commit comments

Comments
 (0)