Add `partialDeepEqual()` in strict assertion mode
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 122k
- Forks
- 37.3k
- Avg merge
- 4d 2h
- Merged PRs (30d)
- 283
Description
What is the problem this feature will solve?
I use strict assertion mode in my tests:
import assert from "node:assert/strict";
assert.equal("...", "...");
assert.deepEqual({ "..." }, { "..." });
assert.partialDeepEqual({ "..." }, { "..." });
But the partialDeepEqual() doesn't exist. You have to use partialDeepStrictEqual() that has the word Strict in its name, whereas the other methods do not.
What is the feature you are proposing to solve the problem?
The "node:assert/strict" module should re-export partialDeepStrictEqual() with the name partialDeepEqual() so that function names are consistent in strict assertion mode.
Additional information
The partialDeepStrictEqual() function was added with https://github.com/nodejs/node/pull/54630. I couldn't find any references to the terms strict assertion mode.
"Re-export" takes place in two locations:
-
Probably for
import assert from "node:assert/strict"
https://github.com/nodejs/node/blob/56aba88702b3a7da4a44688664ff22d8afebb267/lib/assert.js#L126-L131 -
Probably for
import { strict as assert } from "node:assert"
https://github.com/nodejs/node/blob/56aba88702b3a7da4a44688664ff22d8afebb267/lib/assert.js#L894-L899
I don't think adding the following two lines is enough?
// if (options.strict) {
this.partialDeepEqual = this.partialDeepStrictEqual;
// assert.strict = ObjectAssign(strict, assert, {
partialDeepEqual: assert.partialDeepStrictEqual,
Because partialDeepEqual() doesn't exist in legacy assertion mode. So we need to manage the fact that the Assert type will be different between the two modes.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/assert.js at the two linked export locations around lines 126-131 and 894-899, and inspect how strict and legacy assertion modes expose the Assert type. Add the strict-mode alias without adding it to legacy mode, then verify that both import forms expose partialDeepEqual while partialDeepStrictEqual remains available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100