Skip to content

Commit 57312c6

Browse files
committed
fix: deprecate waitFor and waitForElementToBeRemoved on render
1 parent 758cbb1 commit 57312c6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,19 @@ export interface RenderResult<ComponentType, WrapperType = ComponentType>
6363
*/
6464
rerender: (componentProperties: Partial<ComponentType>) => void;
6565
/**
66+
* @deprecated
67+
* Usage of `waitForElementToBeRemoved` from render is deprecated, use this method directly from `@testing-library/angular`
68+
*
6669
* @description
6770
* Wait for the removal of element(s) from the DOM.
6871
*
6972
* For more info see https://testing-library.com/docs/dom-testing-library/api-async#waitforelementtoberemoved
7073
*/
7174
waitForElementToBeRemoved: typeof waitForElementToBeRemoved;
7275
/**
76+
* @deprecated
77+
* Usage of `waitFor` from render is deprecated, use this method directly from `@testing-library/angular`
78+
*
7379
* @description
7480
* When in need to wait for any period of time you can use waitFor, to wait for your expectations to pass.
7581
*

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,15 @@ function replaceFindWithFindAndDetectChanges<T>(container: HTMLElement, original
344344
* Call detectChanges for all fixtures
345345
*/
346346
function detectChangesForMountedFixtures() {
347-
mountedFixtures.forEach(fixture => fixture.detectChanges());
347+
mountedFixtures.forEach(fixture => {
348+
try {
349+
fixture.detectChanges();
350+
} catch (err) {
351+
if (!err.message.startsWith('ViewDestroyedError')) {
352+
throw err;
353+
}
354+
}
355+
});
348356
}
349357

350358
/**

0 commit comments

Comments
 (0)