Skip to content

assert: add partialDeepEqual to strict mode#62332

Closed
semimikoh wants to merge 1 commit intonodejs:mainfrom
semimikoh:assert-add-partialDeepEqual-strict
Closed

assert: add partialDeepEqual to strict mode#62332
semimikoh wants to merge 1 commit intonodejs:mainfrom
semimikoh:assert-add-partialDeepEqual-strict

Conversation

@semimikoh
Copy link
Contributor

The partialDeepStrictEqual method was not re-exported as partialDeepEqual in strict assertion mode, unlike other methods such as deepEqual and equal.

Add the alias so that strict mode users can call
assert.partialDeepEqual() consistently with the existing naming convention.

Fixes: #62327

When using node:assert/strict, methods like deepEqual and equal
are automatically aliased to their strict counterparts. However,
partialDeepStrictEqual was missing this alias.

This PR adds the partialDeepEqual alias in two places:

  1. Assert constructor: when options.strict is true,
    this.partialDeepEqual = this.partialDeepStrictEqual
  2. assert.strict object: partialDeepEqual mapped to
    assert.partialDeepStrictEqual

Tests added in test-assert-class.js and test-assert.js
following the existing alias verification pattern.

Fixes: #62327

The `partialDeepStrictEqual` method was not re-exported as
`partialDeepEqual` in strict assertion mode, unlike other
methods such as `deepEqual` and `equal`.

Add the alias so that strict mode users can call
`assert.partialDeepEqual()` consistently with the existing
naming convention.

Fixes: nodejs#62327
@nodejs-github-bot nodejs-github-bot added assert Issues and PRs related to the assert subsystem. needs-ci PRs that need a full CI run. labels Mar 18, 2026
@Renegade334
Copy link
Member

This doesn't really make sense, because there's no non-strict partialDeepEqual method in the assert module.

The aliases are there such that

const { equal } = require("assert"); // loose equal

is analogous to

const { equal } = require("assert/strict"); // strict equal

but there is no analogous method here.

const { partialDeepEqual } = require("assert"); // undefined

@semimikoh
Copy link
Contributor Author

@Renegade334

That makes sense — I hadn't considered that the aliases exist to map existing non-strict methods to their strict counterparts, not just to remove the "Strict" suffix.

Since there's no partialDeepEqual in the base assert module, adding the alias in strict mode would be inconsistent.

I'll close #62332.

@semimikoh semimikoh closed this Mar 19, 2026
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.68%. Comparing base (d729bec) to head (f72eef0).
⚠️ Report is 763 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #62332      +/-   ##
==========================================
+ Coverage   88.55%   89.68%   +1.13%     
==========================================
  Files         703      676      -27     
  Lines      208259   206581    -1678     
  Branches    40162    39558     -604     
==========================================
+ Hits       184415   185277     +862     
+ Misses      15844    13447    -2397     
+ Partials     8000     7857     -143     
Files with missing lines Coverage Δ
lib/assert.js 98.23% <100.00%> (+<0.01%) ⬆️

... and 355 files with indirect coverage changes

🚀 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.

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

Labels

assert Issues and PRs related to the assert subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add partialDeepEqual() in strict assertion mode

3 participants