Version
29.4.0
Steps to reproduce
- Clone my repository at https://github.com/JamieMagee/jest-structuredclone-strictequal/blob/master/index.spec.js
npm install
npm test
Expected behavior
I expect to see objects cloned with structuredClone to pass toStrictEqual
Actual behavior
The values do not pass toStrictEqual (but do pass toEqual).
jest › toStrictEqual › structured clone
expect(received).toStrictEqual(expected) // deep equality
Expected: {"value": "test"}
Received: serializes to the same string
6 | describe('toStrictEqual', () => {
7 | it('structured clone', () => {
> 8 | expect(structuredClone(value)).toStrictEqual(value);
| ^
9 | });
10 | it('JSON clone', () => {
11 | expect(JSON.parse(JSON.stringify(value))).toStrictEqual(value);
at Object.toStrictEqual (index.spec.js:8:44)
However JSON.parse(JSON.stringify()) does pass toStrictEqual
Additional context
The test output can be seen in this GitHub Actions run.
Environment
System:
OS: Linux 6.2 NixOS 23.05 (Stoat) 23.05 (Stoat)
CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor
Binaries:
Node: 19.7.0 - /run/current-system/sw/bin/node
Yarn: 1.22.19 - /run/current-system/sw/bin/yarn
npm: 9.5.0 - /run/current-system/sw/bin/npm
Version
29.4.0
Steps to reproduce
npm installnpm testExpected behavior
I expect to see objects cloned with
structuredCloneto passtoStrictEqualActual behavior
The values do not pass
toStrictEqual(but do passtoEqual).However
JSON.parse(JSON.stringify())does passtoStrictEqualAdditional context
The test output can be seen in this GitHub Actions run.
Environment