Skip to content

[Bug]: Since Jest 29.1.0 comparing an array of complex class instances throws an error "TypeError: this is not a typed array" #14375

Open
@elchininet

Description

@elchininet

Version

29.1.0

Steps to reproduce

Reproduction of the bug:

  1. Clone this repo. git clone [email protected]:elchininet/isometric.git
  2. Checkout the branch bug-jest. git checkout bug-jest
  3. Install dependencies: yarn
  4. Run this small test: yarn test tests/buggy-test.test.ts
  5. All the tests will pass without any issue (same test using toEqual, toStrictEqual and toMatchObject)
  6. Update jest in package.json from version 29.0.3 to version 29.1.0
  7. Run yarn again to update the package
  8. Run again the small test: yarn test tests/buggy-test.test.ts
  9. The console will hang for a while and at the end it will fail in the test Test with toMatchObject
image

Expected behavior

Jest should not fail with toMatchObject with an array of class instances, it should pass as toEqual or toStrictEqual pass.

Actual behavior

Jest fails to compare an array of class instances with toMatchObject. It even fails with:

expect([rectangle]).toMatchObject([rectangle]);

Additional context

No response

Environment

System: Apple M1 Pro
Binaries:
* Node: v16.15.1
* Yarn: 1.22.19
* npm: 8.11.0
npm packages:
jest `29.0.3` => `29.1.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