You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
assert: surface prototype mismatch in deepStrictEqual diff
deepStrictEqual requires both values to share the same prototype, but
the generated diff may not make that failure cause obvious: when both
values are inspected identically (e.g. an instance of an anonymous
class compared to a plain object) the structural diff shows no
difference at all, and when a subclass is involved the mismatch is
only visible implicitly through the inspected class-name prefix.
Append an explicit "Object prototypes differ: X !== Y" line to the
generated message when the operator is deepStrictEqual, both values
are objects, their top-level prototypes differ, and at least one of
the two prototypes is not a default prototype (Object.prototype,
Array.prototype or null), because those cases are already clearly
visible in the inspect output. The diagnostic covers the top-level
values only; prototype differences of nested objects are not
reported.
The diagnostic is derived defensively: the prototype reads and the
prototype names (derived from a single read of the constructor's
name) are wrapped in a try/catch so that exotic objects (e.g. a Proxy
with a throwing `getPrototypeOf` trap or a stateful `name` getter)
cannot replace the assertion error with a different exception nor
leave the global `Error.stackTraceLimit` modified; the hint is simply
omitted in that case. When the comparison is made with
`skipPrototype: true` (via `new assert.Assert({
skipPrototype: true })`),
the hint is not added because the explicitly ignored difference is
not the cause of the failure.
Refs: #50397
Assisted-by: ZCode (GLM)
Signed-off-by: vaputa <2475834+vaputa@users.noreply.github.com>
0 commit comments