Skip to content

test_runner: full diff option #51902

Open
@malthe

Description

@malthe

What is the problem this feature will solve?

The constructor method for AssertionError currently uses hardcoded limits for showing expected vs actual output. For example, this is how the truncating logic is implemented for the case when the values are not equal:

if (res.length > 512) {
  res = `${StringPrototypeSlice(res, 0, 509)}...`;
}
if (other.length > 512) {
  other = `${StringPrototypeSlice(other, 0, 509)}...`;
}

These limits are not configurable and there are situations where it would be useful to be able to change or entirely remove the limits.

What is the feature you are proposing to solve the problem?

The Jest testing framework has an --expand option that lets you see a full diff which can be useful at times.

The Node CLI could have a similar flag which would remove the default limits, e.g. --assert-expand (which would target the assert library directly).

What alternatives have you considered?

This could be more related to the test runner, but the way it's currently set up, the truncating logic happens when an assertion error is created.

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.

    Type

    No type

    Projects

    Status

    In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions