Repository navigation
fix(@schematics/angular): keep the default getter access type of spyOnProperty in refactor-jasmine-vitest - #34543
Merged
alan-agius4 merged 1 commit intoOct 28, 2026
Conversation
…nProperty in refactor-jasmine-vitest Jasmine spies on getter when `spyOnProperty` gets no access type, migration turned `spyOnProperty(obj, 'prop')` into `vi.spyOn(obj, 'prop')`, which Vitest treats as method spy, so converted spec failed with TS2769 now `'get'` is passed when access type is omited, explicit one is kept
There was a problem hiding this comment.
Code Review
This pull request updates the Jasmine-to-Vitest schematic transformer to correctly handle spyOnProperty calls. When spyOnProperty is invoked with only two arguments, the transformer now appends 'get' as the third argument to vi.spyOn to match Jasmine's default behavior. Additionally, unit tests have been updated and added to verify this default behavior, chained calls, and explicit access types. There are no review comments, and we have no feedback to provide.
alan-agius4
approved these changes
Oct 28, 2026
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
PR Type
What is the current behavior?
Issue Number: N/A
refactor-jasmine-vitestdrops default access type ofspyOnPropertyJasmine uses
'get'when third argument is missing,vi.spyOnwithout it is typed and run as method spyThis spec passes on Jasmine:
ng g @schematics/angular:refactor-jasmine-viteston 22.3.0-next.3 turns it intovi.spyOn(session, 'user').mockReturnValue('mocked')andng testfails to build:Without type check Vitest throws
vi.spyOn() can only spy on a functionat runtimeWhat is the new behavior?
transformPrimarySpyadds'get'whenspyOnPropertyhas two arguments, explict access type is kept as isSame spec converts to
vi.spyOn(session, 'user', 'get').mockReturnValue('mocked')and passes underng testExisting case in
jasmine-spy_spec.tsexpectedvi.spyOn(service, 'myProp').mockReturnValue(undefined)for barespyOnProperty, so it pinned this outputUpdated it and added two cases, chained one and explicit
'set', updated and chained ones fail on mainDoes this PR introduce a breaking change?
Other information
Bare
spyOnProperty(obj, 'prop')still gets.mockReturnValue(undefined)from #33266, so after this change it compiles only when getter type allowsundefined, same as barespyOnon method that returnsstring