From d5fd7349fb8b3942f0727cd7ee62e7a7b231e9e4 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Thu, 24 Apr 2025 11:56:55 +0200 Subject: [PATCH] feat(core): introduce TestBed.tick() (#60993) This commit introduces the `TestBed.tick()` method that, similarly to the `ApplicationRef.tick()`, synchronizes state with the DOM. It can be used in unit tests to mimic framework's logic executed in production applications. The `TestBed.tick()` should be used instead of the removed `TestBed.flushEffects()`. BREAKING CHANGE: the `TestBed.flushEffects()` was removed - use the `TestBed.tick()` instead. PR Close #60993 --- goldens/public-api/core/testing/index.api.md | 2 -- packages/core/testing/src/test_bed.ts | 20 -------------------- 2 files changed, 22 deletions(-) diff --git a/goldens/public-api/core/testing/index.api.md b/goldens/public-api/core/testing/index.api.md index acf641b58be..e98ad1cd8e2 100644 --- a/goldens/public-api/core/testing/index.api.md +++ b/goldens/public-api/core/testing/index.api.md @@ -118,8 +118,6 @@ export interface TestBed { createComponent(component: Type): ComponentFixture; // (undocumented) execute(tokens: any[], fn: Function, context?: any): any; - // @deprecated - flushEffects(): void; initTestEnvironment(ngModule: Type | Type[], platform: PlatformRef, options?: TestEnvironmentOptions): void; // (undocumented) inject(token: ProviderToken, notFoundValue: undefined, options: InjectOptions & { diff --git a/packages/core/testing/src/test_bed.ts b/packages/core/testing/src/test_bed.ts index fd6d88208a4..6ad6864a301 100644 --- a/packages/core/testing/src/test_bed.ts +++ b/packages/core/testing/src/test_bed.ts @@ -152,13 +152,6 @@ export interface TestBed { createComponent(component: Type): ComponentFixture; - /** - * Execute any pending effects. - * - * @deprecated use `TestBed.tick()` instead - */ - flushEffects(): void; - /** * Execute any pending work required to synchronize model to the UI. * @@ -398,10 +391,6 @@ export class TestBedImpl implements TestBed { return TestBedImpl.INSTANCE.ngModule; } - static flushEffects(): void { - return TestBedImpl.INSTANCE.flushEffects(); - } - static tick(): void { return TestBedImpl.INSTANCE.tick(); } @@ -812,15 +801,6 @@ export class TestBedImpl implements TestBed { } } - /** - * Execute any pending effects. - * - * @deprecated use `TestBed.tick()` instead - */ - flushEffects(): void { - this.inject(EffectScheduler).flush(); - } - /** * Execute any pending work required to synchronize model to the UI. *