-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Labels
area: @schematics/angularfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix
Description
Command
generate
Is this a regression?
- Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
refactor-jasmine-vitest skips createSpyObjs if they are only providing one argument. The test are hinting that a call like jasmine.createSpyObj('MyService') is not handlable.
But the first argument doesn't have to be a base name. In fact it is optional
createSpyObj(baseName (opt), methodNames, propertyNames (opt)), see https://jasmine.github.io/api/5.12/jasmine.html
Currently something like
const loggerSpy = jasmine.createSpyObj<LoggingService>(['error']);is transformed to
// TODO: vitest-migration: jasmine.createSpyObj called with a single argument is not supported for transformation. See: https://vitest.dev/api/vi.html#vi-fn
const loggerSpy = jasmine.createSpyObj<LoggingService>(['error']);expected output:
const loggerSpy = { error: vi.fn() };Minimal Reproduction
- follow steps on https://angular.dev/guide/testing/migrating-to-vitest
- call
ng g @schematics/angular:refactor-jasmine-vitest
example spec file:
describe('Foo', () => {
let loggerSpy: jasmine.SpyObj<LoggingService>;
beforeEach(() => {
loggerSpy = jasmine.createSpyObj<LoggingService>(['error']);
});
it('should be fine', () => {
expect(loggerSpy).toBeTruthy();
});
});Exception or Error
Your Environment
Angular CLI : 21.0.0
Angular : 21.0.0
Node.js : 25.1.0 (Unsupported)
Package Manager : npm 11.6.3
Operating System : darwin arm64
┌───────────────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────────────┼───────────────────┼───────────────────┤
│ @angular-devkit/core │ 21.0.0 │ 21.0.0 │
│ @angular/build │ 21.0.0 │ ^21.0.0 │
│ @angular/cdk │ 21.0.0 │ 21.0.0 │
│ @angular/cli │ 21.0.0 │ 21.0.0 │
│ @angular/common │ 21.0.0 │ 21.0.0 │
│ @angular/compiler │ 21.0.0 │ 21.0.0 │
│ @angular/compiler-cli │ 21.0.0 │ 21.0.0 │
│ @angular/core │ 21.0.0 │ 21.0.0 │
│ @angular/forms │ 21.0.0 │ 21.0.0 │
│ @angular/platform-browser │ 21.0.0 │ 21.0.0 │
│ @angular/platform-browser-dynamic │ 21.0.0 │ 21.0.0 │
│ @angular/router │ 21.0.0 │ 21.0.0 │
│ rxjs │ 7.8.2 │ 7.8.2 │
│ typescript │ 5.9.3 │ 5.9.3 │
└───────────────────────────────────┴───────────────────┴───────────────────┘
Anything else relevant?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: @schematics/angularfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix