Skip to content

fix(expect-utils): iterableEquality should not throw on exotic iterables#15952

Open
mhughes2012 wants to merge 4 commits intojestjs:mainfrom
mhughes2012:fix/14375-iterableEquality-no-throw
Open

fix(expect-utils): iterableEquality should not throw on exotic iterables#15952
mhughes2012 wants to merge 4 commits intojestjs:mainfrom
mhughes2012:fix/14375-iterableEquality-no-throw

Conversation

@mhughes2012
Copy link

Summary

Fixes #14375 by ensuring @jest/expect-utils does not throw from iterableEquality (and therefore from matchers like toMatchObject) when it encounters “exotic” iterables whose iteration can throw at runtime (for example, an object whose [Symbol.iterator] is a TypedArray iterator).
Instead of crashing the assertion with TypeError: this is not a typed array., the equality check now treats that case as “not equal”, and a regression test covers the behavior.
(CHANGELOG.md updated.)

Test plan

  • yarn jest packages/expect-utils/src/__tests__/utils.test.ts -t "TypedArray iterator"
  • yarn jest expect-utils

@netlify
Copy link

netlify bot commented Feb 3, 2026

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 7806a14
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/6994e9283ffee5000868659e
😎 Deploy Preview https://deploy-preview-15952--jestjs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 3, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: mhughes2012 / name: Michael Hughes (7806a14)

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 3, 2026

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15952

babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15952

babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15952

create-jest

npm i https://pkg.pr.new/create-jest@15952

@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15952

expect

npm i https://pkg.pr.new/expect@15952

@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15952

jest

npm i https://pkg.pr.new/jest@15952

jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15952

jest-circus

npm i https://pkg.pr.new/jest-circus@15952

jest-cli

npm i https://pkg.pr.new/jest-cli@15952

jest-config

npm i https://pkg.pr.new/jest-config@15952

@jest/console

npm i https://pkg.pr.new/@jest/console@15952

@jest/core

npm i https://pkg.pr.new/@jest/core@15952

@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15952

jest-diff

npm i https://pkg.pr.new/jest-diff@15952

jest-docblock

npm i https://pkg.pr.new/jest-docblock@15952

jest-each

npm i https://pkg.pr.new/jest-each@15952

@jest/environment

npm i https://pkg.pr.new/@jest/environment@15952

jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15952

@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15952

jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15952

@jest/expect

npm i https://pkg.pr.new/@jest/expect@15952

@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15952

@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15952

@jest/globals

npm i https://pkg.pr.new/@jest/globals@15952

jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15952

jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15952

jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15952

jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15952

jest-message-util

npm i https://pkg.pr.new/jest-message-util@15952

jest-mock

npm i https://pkg.pr.new/jest-mock@15952

@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15952

jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15952

jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15952

@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15952

jest-resolve

npm i https://pkg.pr.new/jest-resolve@15952

jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15952

jest-runner

npm i https://pkg.pr.new/jest-runner@15952

jest-runtime

npm i https://pkg.pr.new/jest-runtime@15952

@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15952

jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15952

@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15952

@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15952

@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15952

@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15952

@jest/transform

npm i https://pkg.pr.new/@jest/transform@15952

@jest/types

npm i https://pkg.pr.new/@jest/types@15952

jest-util

npm i https://pkg.pr.new/jest-util@15952

jest-validate

npm i https://pkg.pr.new/jest-validate@15952

jest-watcher

npm i https://pkg.pr.new/jest-watcher@15952

jest-worker

npm i https://pkg.pr.new/jest-worker@15952

pretty-format

npm i https://pkg.pr.new/pretty-format@15952

commit: 7806a14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant