From 4f0fd21d860701fb41feb78f9f530eb0badb11e5 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 29 Sep 2026 09:50:05 +0200 Subject: [PATCH 1/3] build: ban waitForAsync usages `waitForAsync` isn't necessary anymore so we can drop it. --- tslint.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tslint.json b/tslint.json index 25e3677a5a34..fa2a7dc58b71 100644 --- a/tslint.json +++ b/tslint.json @@ -44,6 +44,7 @@ {"name": ["CommonModule"], "message": "Import the necessary symbols directly instead."}, {"name": ["*", "compileComponents"], "message": "`compileComponents` is not necessary."}, {"name": ["*", "hasOwnProperty"], "message": "Use `Object.hasOwn` instead."}, + {"name": ["waitForAsync"], "message": "`waitForAsync is no longer necessary`."}, { "name": ["isDevMode"], "message": "Use `typeof ngDevMode === 'undefined' || ngDevMode` instead" From 29ceae57c17b58b836f7d373131f6452e0c46269 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Tue, 29 Sep 2026 10:21:16 +0200 Subject: [PATCH 2/3] refactor(multiple): remove waitForAsync from tests Tests don't really need to use `waitForAsync` anymore. These changes clean them up. --- .../component-sidenav.spec.ts | 29 +++--- .../shared/guide-items/guide-items.spec.ts | 6 +- .../table-scroll-container.spec.ts | 22 ++--- src/cdk/a11y/focus-trap/focus-trap.spec.ts | 18 ++-- src/cdk/bidi/directionality.spec.ts | 6 +- src/cdk/menu/menu-bar.spec.ts | 6 +- src/cdk/menu/menu-group.spec.ts | 10 +- src/cdk/menu/menu.spec.ts | 6 +- .../private/shared-resize-observer.spec.ts | 14 +-- .../fullscreen-overlay-container.spec.ts | 6 +- src/cdk/overlay/overlay-container.spec.ts | 6 +- .../scroll/block-scroll-strategy.spec.ts | 6 +- .../scroll/reposition-scroll-strategy.spec.ts | 6 +- .../scrolling/virtual-scroll-viewport.spec.ts | 10 +- src/cdk/testing/tests/testbed.spec.ts | 2 + .../autocomplete/autocomplete.zone.spec.ts | 21 ++--- src/material/chips/chip-edit-input.spec.ts | 6 +- src/material/chips/chip-input.spec.ts | 9 +- src/material/chips/chip-option.spec.ts | 6 +- src/material/chips/chip-remove.spec.ts | 6 +- src/material/chips/chip-row.spec.ts | 6 +- src/material/chips/chip.spec.ts | 6 +- src/material/core/option/option.spec.ts | 6 +- .../datepicker/calendar-header.spec.ts | 6 +- src/material/datepicker/calendar.spec.ts | 14 +-- src/material/datepicker/month-view.spec.ts | 10 +- .../datepicker/multi-year-view.spec.ts | 6 +- src/material/datepicker/year-view.spec.ts | 6 +- src/material/expansion/accordion.spec.ts | 6 +- src/material/expansion/expansion.spec.ts | 6 +- src/material/radio/radio.spec.ts | 15 +-- src/material/slider/slider.spec.ts | 92 ++++++++++--------- src/material/tabs/tab-body.spec.ts | 6 +- src/youtube-player/youtube-player.spec.ts | 6 +- 34 files changed, 198 insertions(+), 194 deletions(-) diff --git a/docs/src/app/pages/component-sidenav/component-sidenav.spec.ts b/docs/src/app/pages/component-sidenav/component-sidenav.spec.ts index 8749dd26b288..1cfa1010df93 100644 --- a/docs/src/app/pages/component-sidenav/component-sidenav.spec.ts +++ b/docs/src/app/pages/component-sidenav/component-sidenav.spec.ts @@ -1,8 +1,10 @@ import {provideZoneChangeDetection} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; +import {BreakpointObserver} from '@angular/cdk/layout'; import {MatSidenav} from '@angular/material/sidenav'; import {provideRouter, withComponentInputBinding} from '@angular/router'; import {RouterTestingHarness} from '@angular/router/testing'; +import {of} from 'rxjs'; import {DocumentationItems} from '../../shared/documentation-items/documentation-items'; import {ComponentSidenav, componentSidenavRoutes} from './component-sidenav'; @@ -12,7 +14,16 @@ describe('ComponentSidenav', () => { beforeEach(() => { TestBed.configureTestingModule({ - providers: [provideRouter([]), provideZoneChangeDetection()], + providers: [ + provideRouter([]), + provideZoneChangeDetection(), + { + provide: BreakpointObserver, + useValue: { + observe: () => of({matches: true, breakpoints: {}}), + }, + }, + ], }); fixture = TestBed.createComponent(ComponentSidenav); @@ -21,17 +32,9 @@ describe('ComponentSidenav', () => { }); it('should close the sidenav on init', () => { - // Spy on window.mediaMatch and return stub - spyOn(window, 'matchMedia').and.returnValue({ - matches: true, - } as any); - - // TODO refactor this as none of these expectations are ever verified - waitForAsync(() => { - expect(component.sidenav() instanceof MatSidenav).toBeTruthy(); - expect(component.isScreenSmall()).toBeTruthy(); - expect(component.sidenav()!.opened).toBe(false); - }); + expect(component.sidenav() instanceof MatSidenav).toBeTruthy(); + expect(component.isScreenSmall()).toBeTruthy(); + expect(component.sidenav()!.opened).toBe(false); }); it('should show a link for each item in doc items categories', async () => { diff --git a/docs/src/app/shared/guide-items/guide-items.spec.ts b/docs/src/app/shared/guide-items/guide-items.spec.ts index cd899651364c..a3611bd81424 100644 --- a/docs/src/app/shared/guide-items/guide-items.spec.ts +++ b/docs/src/app/shared/guide-items/guide-items.spec.ts @@ -1,12 +1,12 @@ -import {TestBed, waitForAsync} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import {GuideItems} from './guide-items'; describe('GuideItems', () => { let guideItems: GuideItems; - beforeEach(waitForAsync(() => { + beforeEach(() => { guideItems = TestBed.inject(GuideItems); - })); + }); it('should get a list of all guide items', () => { expect(guideItems.getAllItems()).toBeDefined(); diff --git a/src/cdk-experimental/table-scroll-container/table-scroll-container.spec.ts b/src/cdk-experimental/table-scroll-container/table-scroll-container.spec.ts index ec48d1146064..813373589db2 100644 --- a/src/cdk-experimental/table-scroll-container/table-scroll-container.spec.ts +++ b/src/cdk-experimental/table-scroll-container/table-scroll-container.spec.ts @@ -2,7 +2,7 @@ import {CollectionViewer, DataSource} from '@angular/cdk/collections'; import {Platform} from '@angular/cdk/platform'; import {CdkTable, CdkTableModule} from '@angular/cdk/table'; import {Component, Type, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {BehaviorSubject, combineLatest} from 'rxjs'; import {map} from 'rxjs/operators'; @@ -50,7 +50,7 @@ describe('CdkTableScrollContainer', () => { dataRows = getRows(tableElement); }); - it('sets scrollbar track margin for sticky headers', waitForAsync(async () => { + it('sets scrollbar track margin for sticky headers', async () => { component.stickyHeaders = ['header-1', 'header-3']; fixture.changeDetectorRef.markForCheck(); fixture.detectChanges(); @@ -76,9 +76,9 @@ describe('CdkTableScrollContainer', () => { expect(scrollerStyle.getPropertyValue('margin-right')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-bottom')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-left')).toBe('0px'); - })); + }); - it('sets scrollbar track margin for sticky footers', waitForAsync(async () => { + it('sets scrollbar track margin for sticky footers', async () => { component.stickyFooters = ['footer-1', 'footer-3']; fixture.changeDetectorRef.markForCheck(); fixture.detectChanges(); @@ -104,9 +104,9 @@ describe('CdkTableScrollContainer', () => { expect(scrollerStyle.getPropertyValue('margin-right')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-bottom')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-left')).toBe('0px'); - })); + }); - it('sets scrollbar track margin for sticky start columns', waitForAsync(async () => { + it('sets scrollbar track margin for sticky start columns', async () => { component.stickyStartColumns = ['column-1', 'column-3']; fixture.changeDetectorRef.markForCheck(); fixture.detectChanges(); @@ -134,9 +134,9 @@ describe('CdkTableScrollContainer', () => { expect(scrollerStyle.getPropertyValue('margin-right')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-bottom')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-left')).toBe('0px'); - })); + }); - it('sets scrollbar track margin for sticky end columns', waitForAsync(async () => { + it('sets scrollbar track margin for sticky end columns', async () => { component.stickyEndColumns = ['column-4', 'column-6']; fixture.changeDetectorRef.markForCheck(); fixture.detectChanges(); @@ -164,9 +164,9 @@ describe('CdkTableScrollContainer', () => { expect(scrollerStyle.getPropertyValue('margin-right')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-bottom')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-left')).toBe('0px'); - })); + }); - it('sets scrollbar track margin for a combination of sticky rows and columns', waitForAsync(async () => { + it('sets scrollbar track margin for a combination of sticky rows and columns', async () => { component.stickyHeaders = ['header-1']; component.stickyFooters = ['footer-3']; component.stickyStartColumns = ['column-1']; @@ -202,7 +202,7 @@ describe('CdkTableScrollContainer', () => { expect(scrollerStyle.getPropertyValue('margin-right')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-bottom')).toBe('0px'); expect(scrollerStyle.getPropertyValue('margin-left')).toBe('0px'); - })); + }); }); interface TestData { diff --git a/src/cdk/a11y/focus-trap/focus-trap.spec.ts b/src/cdk/a11y/focus-trap/focus-trap.spec.ts index fb584b81c9d2..79651910c8bd 100644 --- a/src/cdk/a11y/focus-trap/focus-trap.spec.ts +++ b/src/cdk/a11y/focus-trap/focus-trap.spec.ts @@ -9,7 +9,7 @@ import { inject, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {A11yModule, CdkTrapFocus, FocusTrap} from '../index'; @@ -215,7 +215,7 @@ describe('FocusTrap', () => { }); describe('with autoCapture', () => { - it('should automatically capture and return focus on init / destroy', waitForAsync(() => { + it('should automatically capture and return focus on init / destroy', () => { const fixture = TestBed.createComponent(FocusTrapWithAutoCapture); fixture.detectChanges(); @@ -233,9 +233,9 @@ describe('FocusTrap', () => { fixture.detectChanges(); expect(getActiveElement()).toBe(buttonOutsideTrappedRegion); - })); + }); - it('should capture focus if auto capture is enabled later on', waitForAsync(() => { + it('should capture focus if auto capture is enabled later on', () => { const fixture = TestBed.createComponent(FocusTrapWithAutoCapture); fixture.componentInstance.autoCaptureEnabled = false; fixture.componentInstance.showTrappedRegion = true; @@ -256,9 +256,9 @@ describe('FocusTrap', () => { fixture.detectChanges(); expect(getActiveElement()).toBe(buttonOutsideTrappedRegion); - })); + }); - it('should automatically capture and return focus on init / destroy inside the shadow DOM', waitForAsync(() => { + it('should automatically capture and return focus on init / destroy inside the shadow DOM', () => { if (!_supportsShadowDom()) { return; } @@ -280,9 +280,9 @@ describe('FocusTrap', () => { fixture.detectChanges(); expect(getActiveElement()).toBe(buttonOutsideTrappedRegion); - })); + }); - it('should capture focus if auto capture is enabled later on inside the shadow DOM', waitForAsync(() => { + it('should capture focus if auto capture is enabled later on inside the shadow DOM', () => { if (!_supportsShadowDom()) { return; } @@ -307,7 +307,7 @@ describe('FocusTrap', () => { fixture.detectChanges(); expect(getActiveElement()).toBe(buttonOutsideTrappedRegion); - })); + }); }); it('should put anchors inside the outlet when set at the root of a template portal', () => { diff --git a/src/cdk/bidi/directionality.spec.ts b/src/cdk/bidi/directionality.spec.ts index 0c8d05a868e8..c31e8877e16c 100644 --- a/src/cdk/bidi/directionality.spec.ts +++ b/src/cdk/bidi/directionality.spec.ts @@ -1,4 +1,4 @@ -import {waitForAsync, TestBed} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import {Component, ViewChild, signal, inject, ChangeDetectionStrategy} from '@angular/core'; import {By} from '@angular/platform-browser'; import {BidiModule, Directionality, Dir, Direction, DIR_DOCUMENT} from './index'; @@ -6,13 +6,13 @@ import {BidiModule, Directionality, Dir, Direction, DIR_DOCUMENT} from './index' describe('Directionality', () => { let fakeDocument: FakeDocument; - beforeEach(waitForAsync(() => { + beforeEach(() => { fakeDocument = {body: {}, documentElement: {}}; TestBed.configureTestingModule({ providers: [{provide: DIR_DOCUMENT, useFactory: () => fakeDocument}], }); - })); + }); describe('Service', () => { it('should read dir from the html element if not specified on the body', () => { diff --git a/src/cdk/menu/menu-bar.spec.ts b/src/cdk/menu/menu-bar.spec.ts index 3b47dbaa2978..e2e91bfe7a68 100644 --- a/src/cdk/menu/menu-bar.spec.ts +++ b/src/cdk/menu/menu-bar.spec.ts @@ -1,4 +1,4 @@ -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import { Component, ElementRef, @@ -45,14 +45,14 @@ describe('MenuBar', () => { let fixture: ComponentFixture; let menuItems: CdkMenuItemRadio[]; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(MenuBarRadioGroup); fixture.detectChanges(); menuItems = fixture.debugElement .queryAll(By.directive(CdkMenuItemRadio)) .map(element => element.injector.get(CdkMenuItemRadio)); - })); + }); it('should toggle menuitemradio items', () => { expect(menuItems[0].checked).toBeTrue(); diff --git a/src/cdk/menu/menu-group.spec.ts b/src/cdk/menu/menu-group.spec.ts index 73e3e9ef6232..3e92099c3b16 100644 --- a/src/cdk/menu/menu-group.spec.ts +++ b/src/cdk/menu/menu-group.spec.ts @@ -1,5 +1,5 @@ import {Component, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {CdkMenuModule} from './menu-module'; import {CdkMenuItemCheckbox} from './menu-item-checkbox'; @@ -11,7 +11,7 @@ describe('MenuGroup', () => { let fixture: ComponentFixture; let menuItems: CdkMenuItemCheckbox[]; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(CheckboxMenu); fixture.detectChanges(); @@ -21,7 +21,7 @@ describe('MenuGroup', () => { menuItems = fixture.debugElement .queryAll(By.directive(CdkMenuItemCheckbox)) .map(e => e.injector.get(CdkMenuItemCheckbox)); - })); + }); it('should not change state of sibling checked menuitemcheckbox', () => { menuItems[1].trigger(); @@ -34,7 +34,7 @@ describe('MenuGroup', () => { let fixture: ComponentFixture; let menuItems: CdkMenuItemRadio[]; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(MenuWithMultipleRadioGroups); fixture.detectChanges(); @@ -44,7 +44,7 @@ describe('MenuGroup', () => { menuItems = fixture.debugElement .queryAll(By.directive(CdkMenuItemRadio)) .map(e => e.injector.get(CdkMenuItemRadio)); - })); + }); it('should change state of sibling menuitemradio in same group', () => { menuItems[1].trigger({keepOpen: true}); diff --git a/src/cdk/menu/menu.spec.ts b/src/cdk/menu/menu.spec.ts index 8bfd26e24c95..6cb8c73d72e7 100644 --- a/src/cdk/menu/menu.spec.ts +++ b/src/cdk/menu/menu.spec.ts @@ -7,7 +7,7 @@ import { ViewChildren, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import { createMouseEvent, @@ -25,7 +25,7 @@ describe('Menu', () => { let fixture: ComponentFixture; let menuItems: CdkMenuItemCheckbox[]; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(MenuCheckboxGroup); fixture.detectChanges(); @@ -35,7 +35,7 @@ describe('Menu', () => { menuItems = fixture.debugElement .queryAll(By.directive(CdkMenuItemCheckbox)) .map(element => element.injector.get(CdkMenuItemCheckbox)); - })); + }); it('should toggle menuitemcheckbox', () => { expect(menuItems[0].checked).toBeTrue(); diff --git a/src/cdk/observers/private/shared-resize-observer.spec.ts b/src/cdk/observers/private/shared-resize-observer.spec.ts index 9b338cb0912a..1e12a9ca5254 100644 --- a/src/cdk/observers/private/shared-resize-observer.spec.ts +++ b/src/cdk/observers/private/shared-resize-observer.spec.ts @@ -1,4 +1,4 @@ -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {Component, ElementRef, inject, ViewChild, ChangeDetectionStrategy} from '@angular/core'; import {SharedResizeObserver} from './shared-resize-observer'; @@ -93,7 +93,7 @@ describe('SharedResizeObserver', () => { expect(observable1).not.toBe(observable3); }); - it('should receive an initial size on subscription', waitForAsync(async () => { + it('should receive an initial size on subscription', async () => { const observable = resizeObserver.observe(el1); const resizeSpy1 = jasmine.createSpy('resize handler 1'); observable.subscribe(resizeSpy1); @@ -103,9 +103,9 @@ describe('SharedResizeObserver', () => { observable.subscribe(resizeSpy2); fixture.detectChanges(); expect(resizeSpy2).toHaveBeenCalled(); - })); + }); - it('should receive events on resize', waitForAsync(async () => { + it('should receive events on resize', async () => { const resizeSpy = jasmine.createSpy('resize handler'); resizeObserver.observe(el1).subscribe(resizeSpy); fixture.detectChanges(); @@ -113,9 +113,9 @@ describe('SharedResizeObserver', () => { currentObservers.get('content-box')?.triggerCallback(el1); fixture.detectChanges(); expect(resizeSpy).toHaveBeenCalled(); - })); + }); - it('should not receive events for other elements', waitForAsync(async () => { + it('should not receive events for other elements', async () => { const resizeSpy1 = jasmine.createSpy('resize handler 1'); const resizeSpy2 = jasmine.createSpy('resize handler 2'); resizeObserver.observe(el1).subscribe(resizeSpy1); @@ -127,7 +127,7 @@ describe('SharedResizeObserver', () => { fixture.detectChanges(); expect(resizeSpy1).toHaveBeenCalled(); expect(resizeSpy2).not.toHaveBeenCalled(); - })); + }); }); @Component({ diff --git a/src/cdk/overlay/fullscreen-overlay-container.spec.ts b/src/cdk/overlay/fullscreen-overlay-container.spec.ts index aae6c3205270..3628fd99d327 100644 --- a/src/cdk/overlay/fullscreen-overlay-container.spec.ts +++ b/src/cdk/overlay/fullscreen-overlay-container.spec.ts @@ -1,4 +1,4 @@ -import {waitForAsync, TestBed} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import { Component, ViewChild, @@ -16,7 +16,7 @@ describe('FullscreenOverlayContainer', () => { let fullscreenListeners: Set; let fakeDocument: any; - beforeEach(waitForAsync(() => { + beforeEach(() => { fullscreenListeners = new Set(); TestBed.configureTestingModule({ @@ -68,7 +68,7 @@ describe('FullscreenOverlayContainer', () => { injector = TestBed.inject(Injector); fakeDocument = TestBed.inject(DOCUMENT); - })); + }); it('should open an overlay inside a fullscreen element and move it to the body', () => { const fixture = TestBed.createComponent(TestComponentWithTemplatePortals); diff --git a/src/cdk/overlay/overlay-container.spec.ts b/src/cdk/overlay/overlay-container.spec.ts index c2863e175c6a..f565d7a6a28c 100644 --- a/src/cdk/overlay/overlay-container.spec.ts +++ b/src/cdk/overlay/overlay-container.spec.ts @@ -1,4 +1,4 @@ -import {waitForAsync, TestBed} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import { Component, Injector, @@ -13,9 +13,9 @@ import {createOverlayRef, OverlayContainer} from './index'; describe('OverlayContainer', () => { let overlayContainer: OverlayContainer; - beforeEach(waitForAsync(() => { + beforeEach(() => { overlayContainer = TestBed.inject(OverlayContainer); - })); + }); it('should remove the overlay container element from the DOM on destruction', () => { const fixture = TestBed.createComponent(TestComponentWithTemplatePortals); diff --git a/src/cdk/overlay/scroll/block-scroll-strategy.spec.ts b/src/cdk/overlay/scroll/block-scroll-strategy.spec.ts index e305ac25a8b1..5b53a80cab4d 100644 --- a/src/cdk/overlay/scroll/block-scroll-strategy.spec.ts +++ b/src/cdk/overlay/scroll/block-scroll-strategy.spec.ts @@ -1,5 +1,5 @@ import {Component, Injector, ChangeDetectionStrategy} from '@angular/core'; -import {waitForAsync, TestBed} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import {ComponentPortal, PortalModule} from '../../portal'; import {Platform} from '../../platform'; import {ViewportRuler} from '../../scrolling'; @@ -21,7 +21,7 @@ describe('BlockScrollStrategy', () => { let forceScrollElement: HTMLElement; let overlayContainer: OverlayContainer; - beforeEach(waitForAsync(() => { + beforeEach(() => { const injector = TestBed.inject(Injector); const overlayConfig = new OverlayConfig({scrollStrategy: createBlockScrollStrategy(injector)}); @@ -37,7 +37,7 @@ describe('BlockScrollStrategy', () => { forceScrollElement.style.width = '100px'; forceScrollElement.style.height = '3000px'; forceScrollElement.style.background = 'rebeccapurple'; - })); + }); afterEach(() => { overlayRef.dispose(); diff --git a/src/cdk/overlay/scroll/reposition-scroll-strategy.spec.ts b/src/cdk/overlay/scroll/reposition-scroll-strategy.spec.ts index ec37583f6e98..944eb4c9b9fc 100644 --- a/src/cdk/overlay/scroll/reposition-scroll-strategy.spec.ts +++ b/src/cdk/overlay/scroll/reposition-scroll-strategy.spec.ts @@ -1,4 +1,4 @@ -import {waitForAsync, TestBed} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import {Component, Injector, ChangeDetectionStrategy} from '@angular/core'; import {Subject} from 'rxjs'; import {ComponentPortal, PortalModule} from '../../portal'; @@ -19,7 +19,7 @@ describe('RepositionScrollStrategy', () => { let componentPortal: ComponentPortal; let scrolledSubject = new Subject(); - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [ { @@ -34,7 +34,7 @@ describe('RepositionScrollStrategy', () => { injector = TestBed.inject(Injector); overlayContainer = TestBed.inject(OverlayContainer); componentPortal = new ComponentPortal(PastaMsg); - })); + }); afterEach(() => { overlayRef.dispose(); diff --git a/src/cdk/scrolling/virtual-scroll-viewport.spec.ts b/src/cdk/scrolling/virtual-scroll-viewport.spec.ts index 4a22f31b652d..80ddf593288d 100644 --- a/src/cdk/scrolling/virtual-scroll-viewport.spec.ts +++ b/src/cdk/scrolling/virtual-scroll-viewport.spec.ts @@ -16,7 +16,7 @@ import { inject, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {Subject} from 'rxjs'; import {dispatchFakeEvent} from '../testing/private'; @@ -960,11 +960,11 @@ describe('CdkVirtualScrollViewport', () => { let testComponent: DelayedInitializationVirtualScroll; let viewport: CdkVirtualScrollViewport; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(DelayedInitializationVirtualScroll); testComponent = fixture.componentInstance; viewport = testComponent.viewport; - })); + }); it('should call custom trackBy when virtual for is added after init', async () => { await finishInit(fixture); @@ -987,14 +987,14 @@ describe('CdkVirtualScrollViewport', () => { let viewport: CdkVirtualScrollViewport; let contentWrapperEl: HTMLElement; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(VirtualScrollWithAppendOnly); testComponent = fixture.componentInstance; viewport = testComponent.viewport; contentWrapperEl = fixture.nativeElement.querySelector( '.cdk-virtual-scroll-content-wrapper', ) as HTMLElement; - })); + }); it('should not remove item that have already been rendered', async () => { await finishInit(fixture); diff --git a/src/cdk/testing/tests/testbed.spec.ts b/src/cdk/testing/tests/testbed.spec.ts index 4b574d1ca491..176c8bac4137 100644 --- a/src/cdk/testing/tests/testbed.spec.ts +++ b/src/cdk/testing/tests/testbed.spec.ts @@ -83,6 +83,8 @@ describe('TestbedHarnessEnvironment', () => { expect(await harness.getTaskStateResult()).toBe('result'); }); + // Keep `waitForAsync` here since we're testing the integration. + // tslint:disable-next-line:ban it('should be able to wait for tasks outside of Angular within async test zone', waitForAsync(() => { harness.getTaskStateResult().then(res => expect(res).toBe('result')); })); diff --git a/src/material/autocomplete/autocomplete.zone.spec.ts b/src/material/autocomplete/autocomplete.zone.spec.ts index fda0cede343d..f0a26b5958a9 100644 --- a/src/material/autocomplete/autocomplete.zone.spec.ts +++ b/src/material/autocomplete/autocomplete.zone.spec.ts @@ -11,7 +11,7 @@ import { provideZoneChangeDetection, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, ReactiveFormsModule} from '@angular/forms'; import {Subscription} from 'rxjs'; import {MATERIAL_ANIMATIONS, MatOption, ThemePalette} from '../core'; @@ -43,23 +43,22 @@ describe('MatAutocomplete Zone.js integration', () => { fixture.detectChanges(); }); - it('should show the panel when the first open is after the initial zone stabilization', waitForAsync(() => { + it('should show the panel when the first open is after the initial zone stabilization', async () => { // Note that we're running outside the Angular zone, in order to be able // to test properly without the subscription from `_subscribeToClosingActions` // giving us a false positive. - fixture.ngZone!.runOutsideAngular(() => { + await fixture.ngZone!.runOutsideAngular(async () => { fixture.componentInstance.trigger.openPanel(); - Promise.resolve().then(() => { - expect(fixture.componentInstance.panel.showPanel) - .withContext(`Expected panel to be visible.`) - .toBe(true); - }); + await Promise.resolve(); + expect(fixture.componentInstance.panel.showPanel) + .withContext(`Expected panel to be visible.`) + .toBe(true); }); - })); + }); }); - it('should emit from `autocomplete.closed` after click outside inside the NgZone', waitForAsync(async () => { + it('should emit from `autocomplete.closed` after click outside inside the NgZone', async () => { const inZoneSpy = jasmine.createSpy('in zone spy'); const fixture = createComponent(SimpleAutocomplete); @@ -79,7 +78,7 @@ describe('MatAutocomplete Zone.js integration', () => { expect(inZoneSpy).toHaveBeenCalledWith(true); subscription.unsubscribe(); - })); + }); }); @Component({ diff --git a/src/material/chips/chip-edit-input.spec.ts b/src/material/chips/chip-edit-input.spec.ts index 7f5ed42e58d6..f13a39912713 100644 --- a/src/material/chips/chip-edit-input.spec.ts +++ b/src/material/chips/chip-edit-input.spec.ts @@ -1,5 +1,5 @@ import {Component, DebugElement, ChangeDetectionStrategy} from '@angular/core'; -import {waitForAsync, TestBed, ComponentFixture} from '@angular/core/testing'; +import {TestBed, ComponentFixture} from '@angular/core/testing'; import {MatChipEditInput, MatChipsModule} from './index'; import {By} from '@angular/platform-browser'; @@ -10,11 +10,11 @@ describe('MatChipEditInput', () => { let inputDebugElement: DebugElement; let inputInstance: MatChipEditInput; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(ChipEditInputContainer); inputDebugElement = fixture.debugElement.query(By.directive(MatChipEditInput))!; inputInstance = inputDebugElement.injector.get(MatChipEditInput); - })); + }); describe('on initialization', () => { it('should set the initial input text', () => { diff --git a/src/material/chips/chip-input.spec.ts b/src/material/chips/chip-input.spec.ts index c83acbc360c0..a1c57a4aad19 100644 --- a/src/material/chips/chip-input.spec.ts +++ b/src/material/chips/chip-input.spec.ts @@ -6,7 +6,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, DebugElement, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MATERIAL_ANIMATIONS} from '../core'; import {MatFormField} from '../form-field'; @@ -26,16 +26,13 @@ describe('MatChipInput', () => { let inputNativeElement: HTMLInputElement; let chipInputDirective: MatChipInput; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [ provideFakeDirectionality('ltr'), {provide: MATERIAL_ANIMATIONS, useValue: {animationsDisabled: true}}, ], }); - })); - - beforeEach(waitForAsync(() => { fixture = TestBed.createComponent(TestChipInput); testChipInput = fixture.debugElement.componentInstance; fixture.detectChanges(); @@ -43,7 +40,7 @@ describe('MatChipInput', () => { inputDebugElement = fixture.debugElement.query(By.directive(MatChipInput))!; chipInputDirective = inputDebugElement.injector.get(MatChipInput); inputNativeElement = inputDebugElement.nativeElement; - })); + }); describe('basic behavior', () => { it('emits the (chipEnd) on enter keyup', () => { diff --git a/src/material/chips/chip-option.spec.ts b/src/material/chips/chip-option.spec.ts index f3a635581f33..d3015046d224 100644 --- a/src/material/chips/chip-option.spec.ts +++ b/src/material/chips/chip-option.spec.ts @@ -5,7 +5,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, DebugElement, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MAT_RIPPLE_GLOBAL_OPTIONS, RippleGlobalOptions} from '../core'; import { @@ -28,7 +28,7 @@ describe('Option Chips', () => { let hideSingleSelectionIndicator: boolean | undefined; - beforeEach(waitForAsync(() => { + beforeEach(() => { globalRippleOptions = {}; const defaultOptions: MatChipsDefaultOptions = { separatorKeyCodes: [ENTER, SPACE], @@ -42,7 +42,7 @@ describe('Option Chips', () => { {provide: MAT_CHIPS_DEFAULT_OPTIONS, useFactory: () => defaultOptions}, ], }); - })); + }); describe('MatChipOption', () => { let testComponent: SingleChip; diff --git a/src/material/chips/chip-remove.spec.ts b/src/material/chips/chip-remove.spec.ts index 77ca4b51fc7f..03cb757ef33f 100644 --- a/src/material/chips/chip-remove.spec.ts +++ b/src/material/chips/chip-remove.spec.ts @@ -1,7 +1,7 @@ import {ENTER, SPACE} from '@angular/cdk/keycodes'; import {dispatchKeyboardEvent, dispatchMouseEvent} from '@angular/cdk/testing/private'; import {Component, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MatChip, MatChipsModule} from './index'; @@ -10,14 +10,14 @@ describe('Chip Remove', () => { let testChip: TestChip; let chipNativeElement: HTMLElement; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(TestChip); testChip = fixture.debugElement.componentInstance; fixture.detectChanges(); const chipDebugElement = fixture.debugElement.query(By.directive(MatChip))!; chipNativeElement = chipDebugElement.nativeElement; - })); + }); describe('basic behavior', () => { it('should apply a CSS class to the remove icon', () => { diff --git a/src/material/chips/chip-row.spec.ts b/src/material/chips/chip-row.spec.ts index 299a9f4a24ea..d43ef41b69b8 100644 --- a/src/material/chips/chip-row.spec.ts +++ b/src/material/chips/chip-row.spec.ts @@ -14,7 +14,7 @@ import { ViewChild, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import { MatChipEditInput, @@ -31,11 +31,11 @@ describe('Row Chips', () => { let chipNativeElement: HTMLElement; let chipInstance: MatChipRow; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [provideFakeDirectionality('ltr')], }); - })); + }); describe('MatChipRow', () => { let testComponent: SingleChip; diff --git a/src/material/chips/chip.spec.ts b/src/material/chips/chip.spec.ts index b08260c16d1e..f79f41b937cd 100644 --- a/src/material/chips/chip.spec.ts +++ b/src/material/chips/chip.spec.ts @@ -1,6 +1,6 @@ import {provideFakeDirectionality} from '@angular/cdk/testing/private'; import {Component, DebugElement, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MatChip, MatChipEvent, MatChipSet, MatChipsModule} from './index'; @@ -10,11 +10,11 @@ describe('MatChip', () => { let chipNativeElement: HTMLElement; let chipInstance: MatChip; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [provideFakeDirectionality('ltr')], }); - })); + }); describe('MatBasicChip', () => { it('adds a class to indicate that it is a basic chip', () => { diff --git a/src/material/core/option/option.spec.ts b/src/material/core/option/option.spec.ts index 741ad692fb94..3790f5cf849c 100644 --- a/src/material/core/option/option.spec.ts +++ b/src/material/core/option/option.spec.ts @@ -1,4 +1,4 @@ -import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {Component, DebugElement, signal, ChangeDetectionStrategy} from '@angular/core'; import {By} from '@angular/platform-browser'; import { @@ -205,7 +205,7 @@ describe('MatOption component', () => { describe('inside inert group', () => { let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.resetTestingModule(); TestBed.configureTestingModule({ providers: [ @@ -218,7 +218,7 @@ describe('MatOption component', () => { fixture = TestBed.createComponent(InsideGroup); fixture.detectChanges(); - })); + }); it('should remove all accessibility-related attributes from the group', () => { const group: HTMLElement = fixture.nativeElement.querySelector('mat-optgroup'); diff --git a/src/material/datepicker/calendar-header.spec.ts b/src/material/datepicker/calendar-header.spec.ts index 0ff5aa7c293b..ba730d239c5c 100644 --- a/src/material/datepicker/calendar-header.spec.ts +++ b/src/material/datepicker/calendar-header.spec.ts @@ -1,6 +1,6 @@ import {provideFakeDirectionality} from '@angular/cdk/testing/private'; import {Component, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {DateAdapter, provideNativeDateAdapter} from '../core'; import {DEC, FEB, JAN} from '../testing'; @@ -10,12 +10,12 @@ import {MatDatepickerModule} from './datepicker-module'; import {yearsPerPage} from './multi-year-view'; describe('MatCalendarHeader', () => { - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ imports: [MatDatepickerModule], providers: [MatDatepickerIntl, provideFakeDirectionality('ltr'), provideNativeDateAdapter()], }); - })); + }); describe('standard calendar', () => { let fixture: ComponentFixture; diff --git a/src/material/datepicker/calendar.spec.ts b/src/material/datepicker/calendar.spec.ts index eb5977bb3db6..c7da45e5366d 100644 --- a/src/material/datepicker/calendar.spec.ts +++ b/src/material/datepicker/calendar.spec.ts @@ -6,7 +6,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {DateAdapter, provideNativeDateAdapter} from '../core'; import {DEC, FEB, JAN, JUL, NOV} from '../testing'; @@ -17,14 +17,14 @@ describe('MatCalendar', () => { let adapter: DateAdapter; let intl: MatDatepickerIntl; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [MatDatepickerIntl, provideFakeDirectionality('ltr'), provideNativeDateAdapter()], }); adapter = TestBed.inject(DateAdapter); intl = TestBed.inject(MatDatepickerIntl); - })); + }); describe('standard calendar', () => { let fixture: ComponentFixture; @@ -161,7 +161,7 @@ describe('MatCalendar', () => { expect(calendarBodyEl.getAttribute('tabindex')).toBe('-1'); }); - it('should not move focus to the active cell on init', waitForAsync(async () => { + it('should not move focus to the active cell on init', async () => { const activeCell = calendarBodyEl.querySelector( '.mat-calendar-body-active', )! as HTMLElement; @@ -171,9 +171,9 @@ describe('MatCalendar', () => { await new Promise(resolve => setTimeout(resolve)); expect(activeCell.focus).not.toHaveBeenCalled(); - })); + }); - it('should move focus to the active cell when the view changes', waitForAsync(async () => { + it('should move focus to the active cell when the view changes', async () => { calendarInstance.currentView = 'multi-year'; fixture.detectChanges(); @@ -185,7 +185,7 @@ describe('MatCalendar', () => { await new Promise(resolve => setTimeout(resolve)); expect(activeCell.focus).toHaveBeenCalled(); - })); + }); describe('year view', () => { beforeEach(() => { diff --git a/src/material/datepicker/month-view.spec.ts b/src/material/datepicker/month-view.spec.ts index c444fc394140..b159c1b967b5 100644 --- a/src/material/datepicker/month-view.spec.ts +++ b/src/material/datepicker/month-view.spec.ts @@ -21,7 +21,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, signal, WritableSignal, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MAT_DATE_FORMATS, provideNativeDateAdapter} from '../core'; import {DEC, FEB, JAN, MAR, NOV} from '../testing'; @@ -37,7 +37,7 @@ describe('MatMonthView', () => { describe('standard providers', () => { let dir: WritableSignal; - beforeEach(waitForAsync(() => { + beforeEach(() => { dir = signal('ltr'); TestBed.configureTestingModule({ @@ -47,7 +47,7 @@ describe('MatMonthView', () => { {provide: MAT_DATE_RANGE_SELECTION_STRATEGY, useClass: DefaultMatCalendarRangeStrategy}, ], }); - })); + }); describe('standard month view', () => { let fixture: ComponentFixture; @@ -796,7 +796,7 @@ describe('MatMonthView', () => { let fixture: ComponentFixture; let monthViewNativeElement: Element; - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [ provideNativeDateAdapter(), @@ -825,7 +825,7 @@ describe('MatMonthView', () => { let monthViewDebugElement = fixture.debugElement.query(By.directive(MatMonthView))!; monthViewNativeElement = monthViewDebugElement.nativeElement; - })); + }); it('has correct month label', () => { let labelEl = monthViewNativeElement.querySelector('.mat-calendar-body-label')!; diff --git a/src/material/datepicker/multi-year-view.spec.ts b/src/material/datepicker/multi-year-view.spec.ts index 8d4a4864389b..f4f5fb5ee1e8 100644 --- a/src/material/datepicker/multi-year-view.spec.ts +++ b/src/material/datepicker/multi-year-view.spec.ts @@ -15,7 +15,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, signal, ViewChild, WritableSignal, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {provideNativeDateAdapter} from '../core'; import {JAN, MAR} from '../testing'; @@ -25,13 +25,13 @@ import {MatCalendarCellClassFunction} from './calendar-body'; describe('MatMultiYearView', () => { let dir: WritableSignal; - beforeEach(waitForAsync(() => { + beforeEach(() => { dir = signal('ltr'); TestBed.configureTestingModule({ providers: [provideNativeDateAdapter(), provideFakeDirectionality(dir)], }); - })); + }); describe('standard multi-year view', () => { let fixture: ComponentFixture; diff --git a/src/material/datepicker/year-view.spec.ts b/src/material/datepicker/year-view.spec.ts index 1bb1805758c4..617d25fa0369 100644 --- a/src/material/datepicker/year-view.spec.ts +++ b/src/material/datepicker/year-view.spec.ts @@ -15,7 +15,7 @@ import { provideFakeDirectionality, } from '@angular/cdk/testing/private'; import {Component, signal, ViewChild, WritableSignal, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {provideNativeDateAdapter} from '../core'; import {AUG, DEC, FEB, JAN, JUL, JUN, MAR, MAY, NOV, OCT, SEP} from '../testing'; @@ -25,13 +25,13 @@ import {MatCalendarCellClassFunction} from './calendar-body'; describe('MatYearView', () => { let dir: WritableSignal; - beforeEach(waitForAsync(() => { + beforeEach(() => { dir = signal('ltr'); TestBed.configureTestingModule({ providers: [provideNativeDateAdapter(), provideFakeDirectionality(dir)], }); - })); + }); describe('standard year view', () => { let fixture: ComponentFixture; diff --git a/src/material/expansion/accordion.spec.ts b/src/material/expansion/accordion.spec.ts index d1e495268b18..509a5ac3e15e 100644 --- a/src/material/expansion/accordion.spec.ts +++ b/src/material/expansion/accordion.spec.ts @@ -12,7 +12,7 @@ import { ViewChildren, ChangeDetectionStrategy, } from '@angular/core'; -import {TestBed, waitForAsync} from '@angular/core/testing'; +import {TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import { MatAccordion, @@ -25,9 +25,9 @@ import { describe('MatAccordion', () => { let focusMonitor: FocusMonitor; - beforeEach(waitForAsync(() => { + beforeEach(() => { focusMonitor = TestBed.inject(FocusMonitor); - })); + }); it('should ensure only one item is expanded at a time', () => { const fixture = TestBed.createComponent(SetOfItems); diff --git a/src/material/expansion/expansion.spec.ts b/src/material/expansion/expansion.spec.ts index 228c36023389..1295f27a431c 100644 --- a/src/material/expansion/expansion.spec.ts +++ b/src/material/expansion/expansion.spec.ts @@ -5,7 +5,7 @@ import { dispatchKeyboardEvent, } from '@angular/cdk/testing/private'; import {Component, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import { MAT_EXPANSION_PANEL_DEFAULT_OPTIONS, @@ -16,7 +16,7 @@ import { import {MATERIAL_ANIMATIONS} from '../core'; describe('MatExpansionPanel', () => { - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [ { @@ -25,7 +25,7 @@ describe('MatExpansionPanel', () => { }, ], }); - })); + }); it('should expand and collapse the panel', async () => { const fixture = TestBed.createComponent(PanelWithContent); diff --git a/src/material/radio/radio.spec.ts b/src/material/radio/radio.spec.ts index d4a1e7969445..04c1972162c8 100644 --- a/src/material/radio/radio.spec.ts +++ b/src/material/radio/radio.spec.ts @@ -1,6 +1,6 @@ import {dispatchFakeEvent} from '@angular/cdk/testing/private'; import {Component, DebugElement, ViewChild, ChangeDetectionStrategy} from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, FormsModule, NgModel, ReactiveFormsModule} from '@angular/forms'; import {By} from '@angular/platform-browser'; import { @@ -25,7 +25,7 @@ describe('MatRadio', () => { let radioInstances: MatRadioButton[]; let testComponent: RadiosInsideRadioGroup; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = TestBed.createComponent(RadiosInsideRadioGroup); fixture.detectChanges(); @@ -47,7 +47,7 @@ describe('MatRadio', () => { radioFormFieldElements = radioDebugElements.map( debugEl => debugEl.query(By.css('.mdc-form-field'))!.nativeElement, ); - })); + }); it('should set individual radio names based on the group name', () => { expect(groupInstance.name).toBeTruthy(); @@ -997,15 +997,16 @@ describe('MatRadio', () => { let radioDebugElements: DebugElement[]; let radioInstances: MatRadioButton[]; - beforeEach(waitForAsync(() => { + beforeEach(async () => { fixture = TestBed.createComponent(InterleavedRadioGroup); fixture.detectChanges(); + await fixture.whenStable(); groupDebugElement = fixture.debugElement.query(By.directive(MatRadioGroup))!; groupInstance = groupDebugElement.injector.get(MatRadioGroup); radioDebugElements = fixture.debugElement.queryAll(By.directive(MatRadioButton)); radioInstances = radioDebugElements.map(debugEl => debugEl.componentInstance); - })); + }); it('should initialize selection of radios based on model value', () => { expect(groupInstance.selected).toBe(radioInstances[2]); @@ -1023,7 +1024,7 @@ describe('MatRadio', () => { describe('MatRadioDefaultOverrides', () => { describe('when MAT_RADIO_DEFAULT_OPTIONS overridden', () => { - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ providers: [ { @@ -1032,7 +1033,7 @@ describe('MatRadioDefaultOverrides', () => { }, ], }); - })); + }); it('should override default color in Component', () => { const fixture: ComponentFixture = TestBed.createComponent(DefaultRadioButton); diff --git a/src/material/slider/slider.spec.ts b/src/material/slider/slider.spec.ts index a22860c4ae78..1021ebd6aeeb 100644 --- a/src/material/slider/slider.spec.ts +++ b/src/material/slider/slider.spec.ts @@ -22,7 +22,7 @@ import { ViewChildren, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {FormControl, FormGroup, FormsModule, ReactiveFormsModule} from '@angular/forms'; import {By} from '@angular/platform-browser'; import {MatSliderModule} from './slider-module'; @@ -106,13 +106,13 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(StandardSlider); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should set the default values', () => { expect(slider.min).toBe(0); @@ -177,14 +177,14 @@ describe('MatSlider', () => { let endInput: MatSliderRangeThumb; let startInput: MatSliderRangeThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(StandardRangeSlider); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; - })); + }); it('should set the default values', () => { checkInput(startInput, {min: 0, max: 100, value: 0, step: 1, translateX: 0}); @@ -264,13 +264,13 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(SliderWithMinAndMax); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should have the correct initial values', () => { checkInput(input, {min: 25, max: 75, value: 25, translateX: 0}); @@ -343,14 +343,14 @@ describe('MatSlider', () => { let endInput: MatSliderRangeThumb; let startInput: MatSliderRangeThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithMinAndMax); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; - })); + }); it('should have the correct initial values', () => { checkInput(startInput, {min: 25, max: 75, value: 25, translateX: 0}); @@ -545,13 +545,13 @@ describe('MatSlider', () => { let input: MatSliderThumb; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(DisabledSlider); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should be disabled', () => { expect(slider.disabled).toBeTrue(); @@ -587,14 +587,14 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { const fixture = createComponent(DisabledRangeSlider); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should be disabled', () => { expect(slider.disabled).toBeTrue(); @@ -617,7 +617,7 @@ describe('MatSlider', () => { let thumbX: number; let thumbY: number; - beforeEach(waitForAsync(() => { + beforeEach(() => { const fixture = createComponent(StandardSlider); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); @@ -628,7 +628,7 @@ describe('MatSlider', () => { const thumbDimensions = thumbElement.getBoundingClientRect(); thumbX = thumbDimensions.left + thumbDimensions.width / 2; thumbY = thumbDimensions.top + thumbDimensions.height / 2; - })); + }); function isRippleVisible(selector: string) { flushRippleTransitions(); @@ -753,13 +753,13 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { const fixture = createComponent(SliderWithValue); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should set the default value from the attribute', () => { checkInput(input, {min: 0, max: 100, value: 50, translateX: 150}); @@ -776,14 +776,14 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { const fixture = createComponent(RangeSliderWithValue); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should set the correct initial values', async () => { checkInput(startInput, {min: 0, max: 75, value: 25, translateX: 75}); @@ -810,13 +810,13 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(SliderWithStep); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should update to the value based on the step', async () => { await slideToValue(slider, input, 30); @@ -854,14 +854,14 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithStep); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should set the correct start value on slide', async () => { await slideToValue(slider, startInput, 30); @@ -1048,13 +1048,13 @@ describe('MatSlider', () => { let fixture: ComponentFixture; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(SliderWithOneWayBinding); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); const slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should update when bound value changes', () => { fixture.componentInstance.value = 75; @@ -1069,14 +1069,14 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithOneWayBinding); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); const slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should update when bound start value changes', () => { fixture.componentInstance.startValue = 30; @@ -1127,14 +1127,14 @@ describe('MatSlider', () => { let sliderEl: HTMLElement; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(StandardSlider, [provideFakeDirectionality('rtl')]); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; sliderEl = sliderDebugElement.nativeElement; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('works in RTL languages', async () => { await setValueByClick(slider, input, 25, true); @@ -1165,14 +1165,14 @@ describe('MatSlider', () => { let endInput: MatSliderThumb; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(StandardRangeSlider, [provideFakeDirectionality('rtl')]); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('works in RTL languages', async () => { await setValueByClick(slider, startInput, 90, true); @@ -1188,13 +1188,14 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(async () => { fixture = createComponent(SliderWithNgModel); fixture.detectChanges(); + await fixture.whenStable(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should update the model', async () => { await slideToValue(slider, input, 19); @@ -1232,14 +1233,15 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(async () => { fixture = createComponent(RangeSliderWithNgModel); fixture.detectChanges(); + await fixture.whenStable(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should update the models on input value changes', async () => { await slideToValue(slider, startInput, 25); @@ -1333,13 +1335,13 @@ describe('MatSlider', () => { let slider: MatSlider; let input: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(SliderWithFormControl); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should update the control on slide', async () => { expect(fixture.componentInstance.control.value).toBe(0); @@ -1398,14 +1400,14 @@ describe('MatSlider', () => { let startInput: MatSliderThumb; let endInput: MatSliderThumb; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithFormControl); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; - })); + }); it('should update the start input control on slide', async () => { expect(fixture.componentInstance.startInputControl.value).toBe(0); @@ -1538,14 +1540,14 @@ describe('MatSlider', () => { let endInput: MatSliderRangeThumb; let fixture: ComponentFixture; - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithTwoWayBinding); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; - })); + }); it('should sync the start value binding in both directions', async () => { expect(fixture.componentInstance.startValue).toBe(0); @@ -1594,14 +1596,14 @@ describe('MatSlider', () => { return {ticks, active, inactive}; } - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(SliderWithTickMarks); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); slider = sliderDebugElement.componentInstance; sliderEl = sliderDebugElement.nativeElement; input = slider._getInput(_MatThumb.END) as MatSliderThumb; - })); + }); it('should have tick marks', () => { expect(slider._tickMarks.length).toBeTruthy(); @@ -1685,7 +1687,7 @@ describe('MatSlider', () => { return {ticks, active, inactive}; } - beforeEach(waitForAsync(() => { + beforeEach(() => { fixture = createComponent(RangeSliderWithTickMarks); fixture.detectChanges(); const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider)); @@ -1693,7 +1695,7 @@ describe('MatSlider', () => { sliderEl = sliderDebugElement.nativeElement; endInput = slider._getInput(_MatThumb.END) as MatSliderRangeThumb; startInput = slider._getInput(_MatThumb.START) as MatSliderRangeThumb; - })); + }); it('should render the correct number of active & inactive ticks', () => { startInput.value = 0; diff --git a/src/material/tabs/tab-body.spec.ts b/src/material/tabs/tab-body.spec.ts index a2575259556c..879aa3f13c3e 100644 --- a/src/material/tabs/tab-body.spec.ts +++ b/src/material/tabs/tab-body.spec.ts @@ -13,7 +13,7 @@ import { signal, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {MatRippleModule} from '../core'; import {MatTabBody} from './tab-body'; @@ -21,10 +21,10 @@ import {MatTabBody} from './tab-body'; describe('MatTabBody', () => { let dir: WritableSignal; - beforeEach(waitForAsync(() => { + beforeEach(() => { dir = signal('ltr'); TestBed.configureTestingModule({providers: [provideFakeDirectionality(dir)]}); - })); + }); it('should be center position if origin is unchanged', () => { const fixture = TestBed.createComponent(SimpleTabBodyApp); diff --git a/src/youtube-player/youtube-player.spec.ts b/src/youtube-player/youtube-player.spec.ts index 581b1b973c02..a26512523ec0 100644 --- a/src/youtube-player/youtube-player.spec.ts +++ b/src/youtube-player/youtube-player.spec.ts @@ -5,7 +5,7 @@ import { ViewChild, ChangeDetectionStrategy, } from '@angular/core'; -import {ComponentFixture, TestBed, waitForAsync} from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; import {Subscription} from 'rxjs'; import {createFakeYtNamespace} from './fake-youtube-player'; import { @@ -42,13 +42,13 @@ describe('YoutubePlayer', () => { let testComponent: TestApp; let events: Required; - beforeEach(waitForAsync(() => { + beforeEach(() => { const fake = createFakeYtNamespace(); playerCtorSpy = fake.playerCtorSpy; playerSpy = fake.playerSpy; ytWindow.YT = fake.namespace; events = fake.events; - })); + }); function getVideoHost(componentFixture: ComponentFixture): HTMLElement { // Not the most resilient selector, but we don't want to introduce any From 17e47e89fe4926bcff96d153b6c1d3dbd7dacfa7 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Sat, 24 Oct 2026 09:07:57 +0200 Subject: [PATCH 3/3] fix(material/schematics): remove waitForAsync from generated tests Updates the tests generated by `ng generate` not to output `waitForAsync` anymore. --- .../__name@dasherize__.component.spec.ts.template | 6 +++--- .../__name@dasherize__.component.spec.ts.template | 6 +++--- .../__name@dasherize__.component.spec.ts.template | 6 +++--- .../__name@dasherize__.component.spec.ts.template | 6 +++--- .../__name@dasherize__.component.spec.ts.template | 6 +++--- .../__name@dasherize__.component.spec.ts.template | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cdk/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/cdk/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index 8b46e4199275..3619bf6e7357 100644 --- a/src/cdk/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/cdk/schematics/ng-generate/drag-drop/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { <% if(!standalone) { %>waitForAsync, <% } %>ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { DragDropModule } from '@angular/cdk/drag-drop';<% } %> import { <%= classify(name) %>Component } from './<%= dasherize(name) %>.component'; @@ -6,12 +6,12 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [DragDropModule] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component); diff --git a/src/material/schematics/ng-generate/address-form/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/material/schematics/ng-generate/address-form/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index ff5b604dd3e6..b44e73cf8436 100644 --- a/src/material/schematics/ng-generate/address-form/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/material/schematics/ng-generate/address-form/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { ReactiveFormsModule } from '@angular/forms'; import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; @@ -12,7 +12,7 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [ @@ -24,7 +24,7 @@ describe('<%= classify(name) %>Component', () => { MatSelectModule, ] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component); diff --git a/src/material/schematics/ng-generate/dashboard/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/material/schematics/ng-generate/dashboard/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index 7e320757aab3..db4a4d32d717 100644 --- a/src/material/schematics/ng-generate/dashboard/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/material/schematics/ng-generate/dashboard/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { MatButtonModule } from '@angular/material/button'; import { MatCardModule } from '@angular/material/card'; import { MatGridListModule } from '@angular/material/grid-list'; @@ -11,7 +11,7 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [ @@ -22,7 +22,7 @@ describe('<%= classify(name) %>Component', () => { MatMenuModule, ] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component); diff --git a/src/material/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/material/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index 8f628af7ea1d..89738308da5c 100644 --- a/src/material/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/material/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatListModule } from '@angular/material/list'; @@ -11,7 +11,7 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [ @@ -22,7 +22,7 @@ describe('<%= classify(name) %>Component', () => { MatToolbarModule, ] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component); diff --git a/src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index e1f117c06f92..3a2130a4bb25 100644 --- a/src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/material/schematics/ng-generate/table/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; import { MatTableModule } from '@angular/material/table';<% } %> @@ -9,7 +9,7 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [ @@ -18,7 +18,7 @@ describe('<%= classify(name) %>Component', () => { MatTableModule, ] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component); diff --git a/src/material/schematics/ng-generate/tree/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template b/src/material/schematics/ng-generate/tree/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template index 685025ac5943..6bf33af25f69 100644 --- a/src/material/schematics/ng-generate/tree/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template +++ b/src/material/schematics/ng-generate/tree/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.spec.ts.template @@ -1,4 +1,4 @@ -import { <% if(!standalone) { %>waitForAsync, <% } %>ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> +import { ComponentFixture, TestBed } from '@angular/core/testing';<% if(!standalone) { %> import { MatButtonModule } from '@angular/material/button'; import { MatIconModule } from '@angular/material/icon'; import { MatTreeModule } from '@angular/material/tree';<% } %> @@ -9,7 +9,7 @@ describe('<%= classify(name) %>Component', () => { let component: <%= classify(name) %>Component; let fixture: ComponentFixture<<%= classify(name) %>Component>;<% if(!standalone) { %> - beforeEach(waitForAsync(() => { + beforeEach(() => { TestBed.configureTestingModule({ declarations: [<%= classify(name) %>Component], imports: [ @@ -18,7 +18,7 @@ describe('<%= classify(name) %>Component', () => { MatTreeModule, ] }); - }));<% } %> + });<% } %> beforeEach(() => { fixture = TestBed.createComponent(<%= classify(name) %>Component);