Skip to content

Set comparison within expect.objectContaining fails #6820

@danny-does-stuff

Description

@danny-does-stuff

Describe the bug

When comparing Sets within expect.objectContaining, any Set will make the test pass. In other words, the line expect({ set: new Set() }).toEqual(expect.objectContaining({ set: new Set([1]) })); does not cause the test to fail.

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-dpdxnv?file=test%2Fbasic.test.ts

System Info

System:
    OS: macOS 15.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 34.01 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 1.22.22 - /usr/local/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
  Browsers:
    Brave Browser: 128.1.69.168
    Chrome: 109.0.5414.87
    Edge: 130.0.2849.56
    Safari: 18.0.1
    Safari Technology Preview: 18.0

Used Package Manager

yarn

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions