Skip to content

[Bug]: expectation on a structuredClone of a nested map fails with "Method Map.prototype.entries called on incompatible receiver #<Map>" #15591

Open
@TomStrepsil

Description

@TomStrepsil

Version

29.7.0

Steps to reproduce

  1. open https://codesandbox.io/p/devbox/2g2fys
  2. run "npm run test" in terminal

Expected behavior

I expect Jest not to fail, perhaps allow toEqual on the structured clone

Actual behavior

TypeError: Method Map.prototype.entries called on incompatible receiver #<Map>

Additional context

test("it should compare structured cloned maps within maps", () => {
  const item = ["key", new Map([["key", "value"]])];
  const map = new Map([structuredClone(item)]);

  expect(map).toEqual(new Map([[item]]));
});

Environment

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (2) x64 AMD EPYC
  Binaries:
    Node: 20.12.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.5.0 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/share/npm-global/bin/pnpm
  npmPackages:
    jest: ^29.7.0 => 29.7.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions