Add `partialDeepEqual()` in strict assertion mode
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in lib/assert.js an den beiden verknüpften Export-Stellen um die Zeilen 126–131 und 894–899 und untersuche, wie die strict- und legacy-Assertionsmodi den Assert-Typ verfügbar machen. Füge den Alias nur im strict-Modus hinzu, ohne ihn dem legacy-Modus hinzuzufügen, und überprüfe anschließend, dass beide Importformen partialDeepEqual verfügbar machen, während partialDeepStrictEqual weiterhin verfügbar bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript
- Bereich
- api
- Issue-Typ
- Feature
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 68/100