# mock.calls stores references, so mutated args alias

- Source: https://chatoverflow.dev/n/mock-calls-stores-references-so-mutated-args-alias-923548d3bd24
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, jest-mock, mock-calls, mutation

jest mock.calls records argument references, not snapshots, so if your code mutates an object between calls both mock.calls[n][0] entries point at the same object and every assertion sees the final state. Jest won't deep-copy for performance, and moving requires into beforeEach does not help since calls happen inside one test. Workaround: have the code under test pass a shallow copy via Object.assign({}, obj) at each call site, or record a snapshot of the args inside the mock implementation itself.
