Skip to content

Commit d0d2a17

Browse files
committed
feat(@schematics/angular): add Jasmine spy API transformations to jasmine-to-vitest schematic
This commit adds transformers for Jasmine's spying functionality (https://jasmine.github.io/tutorials/spying_on_properties). Coverage includes: - spyOn, spyOnProperty, jasmine.createSpy, and jasmine.createSpyObj - Spy strategies (and.returnValue, and.callFake, etc.) are mapped to Vitest's 'mock*' equivalents. - Inspection of spy calls (spy.calls.reset, spy.calls.mostRecent).
1 parent ad113c7 commit d0d2a17

File tree

3 files changed

+724
-2
lines changed

3 files changed

+724
-2
lines changed

packages/schematics/angular/refactor/jasmine-vitest/test-file-transformer.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ import {
2424
transformWithContext,
2525
transformtoHaveBeenCalledBefore,
2626
} from './transformers/jasmine-matcher';
27+
import {
28+
transformCreateSpyObj,
29+
transformSpies,
30+
transformSpyCallInspection,
31+
transformSpyReset,
32+
} from './transformers/jasmine-spy';
2733
import { RefactorContext } from './utils/refactor-context';
2834
import { RefactorReporter } from './utils/refactor-reporter';
2935

@@ -65,6 +71,11 @@ export function transformJasmineToVitest(
6571
transformSyntacticSugarMatchers,
6672
transformFocusedAndSkippedTests,
6773
transformComplexMatchers,
74+
transformSpies,
75+
transformCreateSpyObj,
76+
transformSpyReset,
77+
transformFocusedAndSkippedTests,
78+
transformSpyCallInspection,
6879
transformPending,
6980
transformDoneCallback,
7081
transformtoHaveBeenCalledBefore,
@@ -75,8 +86,7 @@ export function transformJasmineToVitest(
7586
transformedNode = transformer(transformedNode, refactorCtx);
7687
}
7788
} else if (ts.isPropertyAccessExpression(transformedNode)) {
78-
const transformations = [transformAsymmetricMatchers];
79-
89+
const transformations = [transformAsymmetricMatchers, transformSpyCallInspection];
8090
for (const transformer of transformations) {
8191
transformedNode = transformer(transformedNode, refactorCtx);
8292
}

0 commit comments

Comments
 (0)