Skip to content

[Bug]: toMatchObject incorectly handles nulls in lists of sets #14599

@gorbak25

Description

@gorbak25

Version

29.7.0

Steps to reproduce

For this match

expect([null]).toMatchObject([new Set()]);

Expected behavior

It should throw an exception

Actual behavior

But it doesn't throw an exception. What's interesting is that

expect(null).toMatchObject(new Set()); 

behaves as expected.

Additional context

No response

Environment

System:
    OS: Linux 6.1 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
    CPU: (8) x64 Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz
  Binaries:
    Node: 20.6.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.8.1 - /usr/local/bin/npm
    pnpm: 8.7.5 - /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