Skip to content

Commit e570b52

Browse files
committed
fix(@schematics/angular): suggest valid refactor command after Karma to Vitest migration
After migrating projects, the `migrate-karma-to-vitest` migration suggested running `ng g @schematics/angular:refactor-jasmine-vitest <project_name>`. The schematic does not accept a positional project argument, so the suggested command failed with `Unknown argument`. Suggest the `--project <project_name>` option instead.
1 parent 9469dcd commit e570b52

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎packages/schematics/angular/migrations/migrate-karma-to-vitest/migration.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ function logSummary(
203203
if (migratedProjects.length > 0) {
204204
context.logger.info(
205205
`\nNote: To refactor your test files from Jasmine to Vitest, consider running the following command:` +
206-
`\n ng g @schematics/angular:refactor-jasmine-vitest <project_name>`,
206+
`\n ng g @schematics/angular:refactor-jasmine-vitest --project <project_name>`,
207207
);
208208
}
209209
context.logger.info('-----------------------------------------\n');

‎packages/schematics/angular/migrations/migrate-karma-to-vitest/migration_spec.ts‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,23 @@ describe('Migration from Karma to Vitest unit-test builder', () => {
6868
expect(projects.app.targets.test.options.karmaConfig).toBeUndefined();
6969
});
7070

71+
it('should suggest a valid command to refactor Jasmine tests', async () => {
72+
const logs: string[] = [];
73+
const loggerSubscription = schematicRunner.logger.subscribe(({ message }) =>
74+
logs.push(message),
75+
);
76+
77+
try {
78+
await schematicRunner.runSchematic('migrate-karma-to-vitest', {}, tree);
79+
} finally {
80+
loggerSubscription.unsubscribe();
81+
}
82+
83+
expect(logs.join('\n')).toContain(
84+
'ng g @schematics/angular:refactor-jasmine-vitest --project <project_name>',
85+
);
86+
});
87+
7188
it('should map codeCoverage to coverage', async () => {
7289
const { projects } = tree.readJson('/angular.json') as any;
7390
projects.app.targets.test.options.codeCoverage = true;

0 commit comments

Comments
 (0)