Skip to content

deepStrictEqual and notDeepStrictEqual do not compare Error causes nor AggregateError errors arrays #51793

@Zamralik

Description

@Zamralik

Version

v20.9.0

Platform

Linux DESKTOP-8H17SD6 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  • Compare 2 Error one with a cause and one without
  • Compare 2 Error one with different causes
  • Compare 2 AggregateError with different array of errors

These 4 calls should not throw.
Inversely, replacing notDeepStrictEqual by deepStrictEqual should throw for all.

import { notDeepStrictEqual } from "node:assert";

notDeepStrictEqual(
    new Error('Test'),
    new Error('Test', { cause: new Error('Expected Cause') }),
);

notDeepStrictEqual(
    new Error('Test', { cause: new Error('Unexpected Cause') }),
    new Error('Test'),
);

notDeepStrictEqual(
    new Error('Test', { cause: new Error('Unexpected Cause') }),
    new Error('Test', { cause: new Error('Expected Cause') }),
);

notDeepStrictEqual(
    new AggregateError([], 'Aggregate Test'),
    new AggregateError([new Error('Expected Child')], 'Aggregate Test'),
);

notDeepStrictEqual(
    new AggregateError([new Error('Unexpected Child')], 'Aggregate Test'),
    new AggregateError([], 'Aggregate Test'),
);

notDeepStrictEqual(
    new AggregateError([new Error('Unexpected Child')], 'Aggregate Test'),
    new AggregateError([new Error('Expected Child')], 'Aggregate Test'),
);

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior? Why is that the expected behavior?

notDeepStrictEqual should throw when the Error's cause / AggregateError's errors match perfectly recursively.
deepStrictEqual should throw when the Error's cause / AggregateError's errors do not match perfectly recursively.

What do you see instead?

notDeepStrictEqual throw when the Error's cause / AggregateError's errors match perfectly recursively.
deepStrictEqual do not throw when the Error's cause / AggregateError's errors do not match perfectly recursively.

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    assertIssues and PRs related to the assert subsystem.feature requestIssues that request new features to be added to Node.js.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions