Repository navigation
Conversation
…jasmine-vitest `spy.calls.first()` is migrated to `vi.mocked(spy).mock.calls[0]`, which is alredy arguments array of first call, but `.args` after it was kept so `spy.calls.first().args[0]` became `vi.mocked(spy).mock.calls[0].args[0]`, which fails with TS2339 and throws at runtime `.args` after `first()` is now dropped same way as after `mostRecent()` and `all()[i]`
There was a problem hiding this comment.
Code Review
This pull request extends the Jasmine-to-Vitest migration schematic to support transforming spy.calls.first().args and its indexed accesses into the Vitest equivalent vi.mocked(spy).mock.calls[0]. It updates the AST transformer to handle .first calls similarly to .mostRecent and adds corresponding unit tests to verify the behavior. No review comments were provided, and the implementation is clean and correct.
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-vitestturnsspy.calls.first()intovi.mocked(spy).mock.calls[0], which is argumnets array of first call, and keeps.argsthat follows itSo
expect(spy.calls.first().args[0]).toBe(1)becomesexpect(vi.mocked(spy).mock.calls[0].args[0]).toBe(1)and converted spec does not build withng test(checked on 22.3.0-next.3):Without type check it throws
Cannot read properties of undefined (reading '0')mostRecent().argsandall()[i].args(#33206) already drop.args, onlyfirst()was missedWhat is the new behavior?
spy.calls.first().argsbecomesvi.mocked(spy).mock.calls[0], in same transformer that handlesmostRecent().argsSame spec after conversion builds and passes with
ng testTwo new cases in
jasmine-spy_spec.ts, both fail on mainDoes this PR introduce a breaking change?
Other information