Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: full diff option #51902

Open
malthe opened this issue Feb 27, 2024 · 1 comment · May be fixed by #52921
Open

test_runner: full diff option #51902

malthe opened this issue Feb 27, 2024 · 1 comment · May be fixed by #52921
Assignees
Labels
assert Issues and PRs related to the assert subsystem. feature request Issues that request new features to be added to Node.js.

Comments

@malthe
Copy link
Contributor

malthe commented Feb 27, 2024

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.

@malthe malthe added the feature request Issues that request new features to be added to Node.js. label Feb 27, 2024
@MoLow MoLow added the assert Issues and PRs related to the assert subsystem. label Feb 28, 2024
@RedYetiDev RedYetiDev self-assigned this May 9, 2024
@RedYetiDev
Copy link
Member

I'll take this on :-). Currently, I'm implementing this as --full-assert-diff, but the name can be changed.

@RedYetiDev RedYetiDev linked a pull request May 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
assert Issues and PRs related to the assert subsystem. feature request Issues that request new features to be added to Node.js.
Projects
Status: Pending Triage
Development

Successfully merging a pull request may close this issue.

3 participants