Skip to content

Commit a640f5c

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

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ 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,
2426
} from '@testing-library/dom';
2527
import { RenderComponentOptions, RenderDirectiveOptions, RenderTemplateOptions, RenderResult } from './models';
2628
import { getConfig } from './config';
@@ -432,6 +434,14 @@ function detectChangesForMountedFixtures() {
432434
*/
433435
const screen = replaceFindWithFindAndDetectChanges(dtlScreen);
434436

437+
/**
438+
* Re-export within with patched queries
439+
*/
440+
function within(element: HTMLElement, queriesToBind?: Queries) {
441+
const container = dtlWithin(element, queriesToBind);
442+
return replaceFindWithFindAndDetectChanges(container);
443+
}
444+
435445
/**
436446
* Re-export waitFor with patched waitFor
437447
*/
@@ -516,8 +526,7 @@ export {
516526
queryAllByAttribute,
517527
queryByAttribute,
518528
queryHelpers,
519-
within,
520529
} from '@testing-library/dom';
521530

522531
// export patched dtl
523-
export { screen, waitFor, waitForElementToBeRemoved };
532+
export { screen, waitFor, waitForElementToBeRemoved, within };

0 commit comments

Comments
 (0)