When using property matchers in snapshots (https://jestjs.io/docs/en/snapshot-testing#property-matchers) the matcher mutates the object.
test('some test', () => {
const object = { foo: 'bar' };
expect(typeof object.foo).toBe('string');
expect(object).toMatchSnapshot({ foo: expect.any(String) });
expect(typeof object.foo).toBe('string');
});
That test will fail the last assertion.

The passed in object should not be mutated.
REPL is on Jest 22, but see "To reproduce"
npx envinfo --preset jestPaste the results here:
System:
OS: macOS Sierra 10.12.6
CPU: x64 Intel(R) Core(TM) i7-4980HQ CPU @ 2.80GHz
Binaries:
Node: 8.11.1 - ~/.nvm/versions/node/v8.11.1/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - ~/.nvm/versions/node/v8.11.1/bin/npm
npmPackages:
jest: ^23.1.0 => 23.1.0
Note that this _might_ be solved by #6528, but that might take some time to land, so opening up a separate issue.
Fix should be here: https://github.com/facebook/jest/blob/6c61baa76e366a9a7bfb351108a2d4ca97820bf9/packages/jest-snapshot/src/index.js#L147
(don't Object.assign into received)
Oops, duh
Yeah #6528 will solve this and has a test for it
Most helpful comment
Oops, duh