Skip to content

fix(expect): handle ArrayBuffers, DataViews, error constructors, and boxed primitives in toStrictEqual - #7393

Open
helmipradita wants to merge 1 commit into
denoland:mainfrom
helmipradita:fix/expect-tostrictequal-edge-cases
Open

helmipradita wants to merge 1 commit into
denoland:mainfrom
helmipradita:fix/expect-tostrictequal-edge-cases

Conversation

@helmipradita

Copy link
Copy Markdown

Refs #7387

Description

In @std/expect equality matching (particularly under strictCheck: true for toStrictEqual):

  1. Error constructors: a instanceof Error && b instanceof Error checked only a.message === b.message before strict constructor check, causing new Error("m") and new TypeError("m") to evaluate as equal.
  2. ArrayBuffers & DataViews: Missing byte content checks meant buffers with different contents evaluated as equal because they share empty own keys.
  3. Null-prototype objects: constructorsEqual treated !a.constructor && b.constructor === Object as equal; with strictCheck: true it now requires exact constructor equality (a.constructor === b.constructor), correctly rejecting Object.create(null) against {}.
  4. Boxed primitives: Number, Boolean, Symbol, and BigInt wrapper objects now compare their underlying values via sameValueZero.
  5. Keyed collections: Tracking unmatched entries with a Set in _equal.ts and _utils.ts (iterableEquality) prevents duplicate object entries in a from repeatedly matching the same entry in b.

@github-actions github-actions Bot added the expect label Nov 8, 2026
@codecov

codecov Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.76471% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.02%. Comparing base (f834d02) to head (f31ceb9).

Files with missing lines Patch % Lines
expect/_equal.ts 86.53% 2 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7393      +/-   ##
==========================================
- Coverage   95.04%   95.02%   -0.02%     
==========================================
  Files         619      618       -1     
  Lines       52012    51799     -213     
  Branches     9450     9424      -26     
==========================================
- Hits        49434    49224     -210     
+ Misses       2031     2022       -9     
- Partials      547      553       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant