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

util: expose diff function used by the assertion errors #57462

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

puskin94
Copy link
Contributor

fix: #51740

Exporting the new util.diff(actual, expected) function.

This function is the one internally used by the assert module when an AssertionError occurs and it is just an utility to better show differences between the two params actual and expected.

It is internally using the "new" Myers diff algorithm so you can expect the same output provided by this PR: #54862

@nodejs-github-bot nodejs-github-bot added assert Issues and PRs related to the assert subsystem. needs-ci PRs that need a full CI run. util Issues and PRs related to the built-in util module. labels Mar 14, 2025
@puskin94 puskin94 force-pushed the util-add-diff-function branch from 1905f00 to 480d3c7 Compare March 14, 2025 15:28
@puskin94 puskin94 changed the title util: expose diff function used by the assertion errors. util: expose diff function used by the assertion errors Mar 14, 2025
Copy link

codecov bot commented Mar 14, 2025

Codecov Report

Attention: Patch coverage is 95.65217% with 3 lines in your changes missing coverage. Please review.

Project coverage is 90.23%. Comparing base (3329efe) to head (dd09392).
Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/assert/myers_diff.js 85.71% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57462      +/-   ##
==========================================
+ Coverage   90.20%   90.23%   +0.02%     
==========================================
  Files         629      630       +1     
  Lines      184948   184898      -50     
  Branches    36204    36217      +13     
==========================================
- Hits       166837   166834       -3     
+ Misses      11057    11019      -38     
+ Partials     7054     7045       -9     
Files with missing lines Coverage Δ
lib/internal/util/diff.js 100.00% <100.00%> (ø)
lib/util.js 97.75% <100.00%> (+0.04%) ⬆️
lib/internal/assert/myers_diff.js 89.20% <85.71%> (+0.31%) ⬆️

... and 56 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change LGTM with one nit about the docs.

@puskin94 puskin94 force-pushed the util-add-diff-function branch from 480d3c7 to 518712d Compare March 14, 2025 18:00
@benjamingr benjamingr added the notable-change PRs with changes that should be highlighted in changelogs. label Mar 15, 2025
Copy link
Contributor

The notable-change PRs with changes that should be highlighted in changelogs. label has been added by @benjamingr.

Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section.

Copy link
Member

@pmarchini pmarchini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (only one nit)

@puskin94 puskin94 force-pushed the util-add-diff-function branch 2 times, most recently from 549a8b6 to 1a33a1c Compare March 17, 2025 11:11
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good!

I would still consider changing the output format to be the most performant one we can think of. I would likely change it to: [type, value], where type would be one of -1, 0, 1.

@puskin94 puskin94 force-pushed the util-add-diff-function branch 3 times, most recently from f4b06e7 to fe1f36c Compare March 17, 2025 14:17
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! This is shaping up well!

Two small things, otherwise it's LGTM

@puskin94 puskin94 force-pushed the util-add-diff-function branch from fe1f36c to dd09392 Compare March 17, 2025 15:30
@pmarchini pmarchini added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 17, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 17, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR added the semver-minor PRs that contain new features and should be released in the next minor version. label Mar 19, 2025
Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work

@BridgeAR BridgeAR added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 19, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 19, 2025
@nodejs-github-bot nodejs-github-bot merged commit 6b42554 into nodejs:main Mar 19, 2025
66 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 6b42554

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. author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version. util Issues and PRs related to the built-in util module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose createErrDiff for diffing objects
6 participants