Skip to content

Commit ab00e2c

Browse files
committed
build: overlay container not being cleaned up in global overlay tests
Fixes the `GlobalPositionStrategy` tests leaking `.cdk-overlay-container` instances which can cause flakes in other tests.
1 parent 008ee07 commit ab00e2c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/cdk/overlay/position/global-position-strategy.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {NgModule, NgZone, Component} from '@angular/core';
22
import {TestBed, inject} from '@angular/core/testing';
33
import {MockNgZone} from '@angular/cdk/testing';
44
import {PortalModule, ComponentPortal} from '@angular/cdk/portal';
5-
import {OverlayModule, Overlay, OverlayConfig, OverlayRef} from '../index';
5+
import {OverlayModule, Overlay, OverlayConfig, OverlayRef, OverlayContainer} from '../index';
66

77

88
describe('GlobalPositonStrategy', () => {
@@ -21,12 +21,14 @@ describe('GlobalPositonStrategy', () => {
2121
})();
2222
});
2323

24-
afterEach(() => {
24+
afterEach(inject([OverlayContainer], (overlayContainer: OverlayContainer) => {
2525
if (overlayRef) {
2626
overlayRef.dispose();
2727
overlayRef = null!;
2828
}
29-
});
29+
30+
overlayContainer.ngOnDestroy();
31+
}));
3032

3133
function attachOverlay(config: OverlayConfig): OverlayRef {
3234
const portal = new ComponentPortal(BlankPortal);

0 commit comments

Comments
 (0)