From 45d63602a9c32b9c885ccce8b9f749616c0b217b Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Fri, 9 Oct 2026 12:47:54 +0200 Subject: [PATCH] build: ban new usages of fakeAsync Updates the lint rules to avoid adding new usages of `fakeAsync`. --- src/cdk/testing/tests/testbed.spec.ts | 4 ++++ tslint.json | 1 + 2 files changed, 5 insertions(+) diff --git a/src/cdk/testing/tests/testbed.spec.ts b/src/cdk/testing/tests/testbed.spec.ts index 7f04954f5974..4b574d1ca491 100644 --- a/src/cdk/testing/tests/testbed.spec.ts +++ b/src/cdk/testing/tests/testbed.spec.ts @@ -87,6 +87,8 @@ describe('TestbedHarnessEnvironment', () => { harness.getTaskStateResult().then(res => expect(res).toBe('result')); })); + // Testing the integration with fakeAsync. + // tslint:disable-next-line:ban it('should be able to wait for tasks outside of Angular within fakeAsync test zone', fakeAsync(async () => { expect(await harness.getTaskStateResult()).toBe('result'); })); @@ -96,6 +98,8 @@ describe('TestbedHarnessEnvironment', () => { expect(element.id).toContain('root'); }); + // Testing the integration with fakeAsync. + // tslint:disable-next-line:ban it('should wait for async operation to complete in fakeAsync test', fakeAsync(async () => { const asyncCounter = await harness.asyncCounter(); expect(await asyncCounter.text()).toBe('5'); diff --git a/tslint.json b/tslint.json index 3ef24bc0c784..25e3677a5a34 100644 --- a/tslint.json +++ b/tslint.json @@ -36,6 +36,7 @@ ["fdescribe"], ["xit"], ["xdescribe"], + {"name": ["fakeAsync"], "message": "`fakeAsync` tests are no longer allowed."}, {"name": ["first"], "message": "Use take(1) instead."}, {"name": ["Object", "assign"], "message": "Use the spread operator instead."}, {"name": ["*", "asObservable"], "message": "Cast to Observable type instead."},