Add `partialDeepEqual()` in strict assertion mode
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.3k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
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.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en lib/assert.js, en las dos ubicaciones de exportación enlazadas alrededor de las líneas 126-131 y 894-899, e inspecciona cómo los modos de aserción strict y legacy exponen el tipo Assert. Añade el alias al modo strict sin añadirlo al modo legacy y, después, verifica que ambas formas de importación expongan partialDeepEqual, mientras que partialDeepStrictEqual siga estando disponible.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- api
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 68/100