Skip to content

Commit 3707db7

Browse files
committed
fixup! feat(@schematics/angular): migrate fake async to Vitest fake timers
1 parent e3ff0a2 commit 3707db7

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

packages/schematics/angular/refactor/jasmine-vitest/transformers/fake-async-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ function _transformFakeAsyncCall(
109109

110110
return ts.factory.createArrowFunction(
111111
[ts.factory.createModifier(ts.SyntaxKind.AsyncKeyword)],
112-
undefined,
113-
[],
112+
fakeAsyncCallback.typeParameters,
113+
fakeAsyncCallback.parameters,
114114
undefined,
115115
ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken),
116116
ts.factory.createBlock(callbackBody.statements),

packages/schematics/angular/refactor/jasmine-vitest/transformers/fake-async-test_spec.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,32 @@ describe('transformFakeAsyncTest', () => {
3535
});
3636
`,
3737
},
38+
{
39+
description:
40+
'should transform fakeAsync test to `vi.useFakeTimers()` and keep its arguments but not the return type',
41+
input: `
42+
import { fakeAsync } from '@angular/core/testing';
43+
44+
describe('My fakeAsync suite', () => {
45+
it('works', fakeAsync((strangeArg: Strange): void => {
46+
expect(1).toBe(1);
47+
}));
48+
});
49+
`,
50+
expected: `
51+
describe('My fakeAsync suite', () => {
52+
beforeAll(() => {
53+
vi.useFakeTimers({ advanceTimeDelta: 1, shouldAdvanceTime: true });
54+
});
55+
afterAll(() => {
56+
vi.useRealTimers();
57+
});
58+
it('works', async (strangeArg: Strange) => {
59+
expect(1).toBe(1);
60+
});
61+
});
62+
`,
63+
},
3864
{
3965
description: 'should transform fakeAsync test to `vi.useFakeTimers()` in outer describe',
4066
input: `

0 commit comments

Comments
 (0)