Skip to content

Commit 8289333

Browse files
committed
fix(@schematics/angular): improve comment preservation in jasmine-to-vitest
This commit improves the preservation of comments during the `jasmine-to-vitest` transformation. Specifically, it fixes an issue where multi-line comments between chained spy calls were being discarded. The transformer has been updated to use a less destructive AST modification pattern, which successfully preserves this trivia. Additionally, a previously failing test case for this scenario has been re-enabled and is now passing.
1 parent f93a8e8 commit 8289333

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ describe('Jasmine to Vitest Transformer', () => {
151151
*/
152152
.mockReturnValue(true);
153153
`,
154-
skipped: true,
154+
skipped: false,
155155
},
156156
{
157157
description: 'should preserve a trailing comment on a matcher line',

packages/schematics/angular/refactor/jasmine-vitest/transformers/jasmine-spy.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ export function transformSpies(node: ts.Node, refactorCtx: RefactorContext): ts.
160160
node,
161161
`Transformed spy strategy \`.and.${strategyName}()\` to \`.${newMethodName}()\`.`,
162162
);
163-
const newExpression = createPropertyAccess(spyCall, newMethodName);
163+
164+
const newExpression = ts.factory.updatePropertyAccessExpression(
165+
pae,
166+
spyCall,
167+
ts.factory.createIdentifier(newMethodName),
168+
);
164169

165170
return ts.factory.updateCallExpression(
166171
node,

0 commit comments

Comments
 (0)