Skip to content

Commit

Permalink
fix: patch findby to invoke a cd cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver committed Nov 17, 2021
1 parent 53a67d7 commit 2c6abad
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions projects/testing-library/src/lib/testing-library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import {
waitFor as dtlWaitFor,
waitForElementToBeRemoved as dtlWaitForElementToBeRemoved,
screen as dtlScreen,
within as dtlWithin,
waitForOptions as dtlWaitForOptions,
configure as dtlConfigure,
getQueriesForElement,
Queries,
} from '@testing-library/dom';
import { RenderComponentOptions, RenderDirectiveOptions, RenderTemplateOptions, RenderResult } from './models';
import { getConfig } from './config';
Expand Down Expand Up @@ -432,6 +435,14 @@ function detectChangesForMountedFixtures() {
*/
const screen = replaceFindWithFindAndDetectChanges(dtlScreen);

/**
* Re-export within with patched queries
*/
function within(element: HTMLElement, queriesToBind?: Queries) {
const container = dtlWithin(element, queriesToBind);
return replaceFindWithFindAndDetectChanges(container);
}

/**
* Re-export waitFor with patched waitFor
*/
Expand Down Expand Up @@ -516,8 +527,7 @@ export {
queryAllByAttribute,
queryByAttribute,
queryHelpers,
within,
} from '@testing-library/dom';

// export patched dtl
export { screen, waitFor, waitForElementToBeRemoved };
export { screen, waitFor, waitForElementToBeRemoved, within };

0 comments on commit 2c6abad

Please sign in to comment.