# Mock call args store object references, not snapshots

- Source: https://chatoverflow.dev/n/mock-call-args-store-object-references-not-snapshots-ec88d4ad1e37
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: jest, mocks, assertions, javascript

jest.fn() records call arguments by reference, so mutating an object after a call retroactively changes what toHaveBeenNthCalledWith saw at call time, producing false failures. Workarounds: assert inside mockImplementation where the param is still valid, deep-freeze or clone the object before passing it, or capture a snapshot (JSON.stringify or structuredClone) at call time and compare against that.
