diff --git a/packages/utils/src/helpers.ts b/packages/utils/src/helpers.ts index e0fca92c693a..5a3b454a8d8b 100644 --- a/packages/utils/src/helpers.ts +++ b/packages/utils/src/helpers.ts @@ -97,7 +97,7 @@ export function clone( if (Array.isArray(val)) { out = Array((k = val.length)) seen.set(val, out) - while (k--) out[k] = clone(val[k], seen) + while (k--) out[k] = clone(val[k], seen, options) return out as any } @@ -110,7 +110,7 @@ export function clone( const descriptor = Object.getOwnPropertyDescriptor(val, k) if (!descriptor) continue - const cloned = clone((val as any)[k], seen) + const cloned = clone((val as any)[k], seen, options) if ('get' in descriptor) { Object.defineProperty(out, k, { ...descriptor, diff --git a/test/core/test/jest-expect.test.ts b/test/core/test/jest-expect.test.ts index f51ddb967a52..9387910cc0b9 100644 --- a/test/core/test/jest-expect.test.ts +++ b/test/core/test/jest-expect.test.ts @@ -303,6 +303,13 @@ describe('jest-expect', () => { expect(() => { expect(complex).toHaveProperty('a-b', false) }).toThrowErrorMatchingInlineSnapshot('"expected { \'0\': \'zero\', foo: 1, …(4) } to have property "a-b" with value false"') + + expect(() => { + const x = { a: { b: { c: 1 } } } + const y = { a: { b: { c: 2 } } } + Object.freeze(x.a) + expect(x).toEqual(y) + }).toThrowErrorMatchingInlineSnapshot(`"expected { a: { b: { c: 1 } } } to deeply equal { a: { b: { c: 2 } } }"`) }) it('assertions', () => {