Skip to content

Commit eaf2343

Browse files
clydinalan-agius4
authored andcommitted
fix(@schematics/angular): migrate CallInfo returnValue and object in refactor-jasmine-vitest
Previously, only the `.args` property of a Jasmine `CallInfo` object obtained via `spy.calls.first()`, `spy.calls.mostRecent()`, or `spy.calls.all()[i]` was migrated. Accessing `.returnValue` or `.object` on these results left the property intact on the transformed `mock.calls[i]` tuple, producing code that fails type checking and throws at runtime. These properties are now mapped to the corresponding Vitest `MockContext` members: - `spy.calls.first().returnValue` -> `vi.mocked(spy).mock.results[0].value` - `spy.calls.all()[i].returnValue` -> `vi.mocked(spy).mock.results[i].value` - `spy.calls.mostRecent().returnValue` -> `vi.mocked(spy).mock.results.at(-1)?.value` - `spy.calls.first().object` -> `vi.mocked(spy).mock.contexts[0]` - `spy.calls.all()[i].object` -> `vi.mocked(spy).mock.contexts[i]` - `spy.calls.mostRecent().object` -> `vi.mocked(spy).mock.contexts.at(-1)` The separate `transformMostRecentArgs` and `transformAllCallsArgs` handlers have been consolidated into a single `transformCallInfoProperty` transformer, and the TODO for a bare `mostRecent()` call no longer fires when one of the supported properties is accessed. (cherry picked from commit 54f2618)
1 parent ad04d68 commit eaf2343

3 files changed

Lines changed: 308 additions & 107 deletions

File tree

0 commit comments

Comments
 (0)