Skip to content

Commit 050a027

Browse files
devversionjelbourn
authored andcommitted
test: dialog harness tests leak open dialogs (#16983)
Ensures that the mdc-dialog harness tests do not leak open dialogs.
1 parent f594271 commit 050a027

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/material-experimental/mdc-dialog/harness/dialog-harness.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@ describe('MatDialogHarness', () => {
3838

3939
/** Shared tests to run on both the original and MDC-based radio-button's. */
4040
function runTests() {
41+
afterEach(() => {
42+
// Close all dialogs upon test exit. This is necessary because the "MatDialog"
43+
// service is not destroyed in TestBed automatically, and it could mean that
44+
// dialogs are left in the DOM.
45+
fixture.componentInstance.dialog.closeAll();
46+
fixture.detectChanges();
47+
});
48+
4149
it('should load harness for dialog', async () => {
4250
fixture.componentInstance.open();
4351
const dialogs = await loader.getAllHarnesses(dialogHarness);

0 commit comments

Comments
 (0)