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

fix(assert): add formatting for assertNotEquals error messages #6246

Merged
merged 2 commits into from
Dec 10, 2024

Conversation

IgorM867
Copy link
Contributor

@IgorM867 IgorM867 commented Dec 9, 2024

As mentioned in #4955, this PR changes the way messages are formatted in assertNotEquals.

Current errors

Code: assertNotEquals("1", "1");

Output: error: AssertionError: Expected actual: 1 not to be: 1.


Code: assertNotEquals({ foo: 1 }, { foo: 1 });

Output:
error: AssertionError: Expected actual: [object Object] not to be: [object Object].


Code: assertNotEquals([1, 2], [1, 2]);

Output: error: AssertionError: Expected actual: 1,2 not to be: 1,2.


Errors after fix

Code:

assertNotEquals("1", "1");

Output:

error: AssertionError: Expected actual: "1" not to be: "1".

Code:

assertNotEquals({ foo: 1 }, { foo: 1 });

Output:

error: AssertionError: Expected actual: {
  foo: 1,
} not to be: {
  foo: 1,
}.

Code:

assertNotEquals([1, 2], [1, 2]);

Output:

error: AssertionError: Expected actual: [
  1,
  2,
] not to be: [
  1,
  2,
].

Fixes #4955

@IgorM867 IgorM867 requested a review from kt3k as a code owner December 9, 2024 08:55
@github-actions github-actions bot added the assert label Dec 9, 2024
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.51%. Comparing base (b2b7f99) to head (acb1c1f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6246      +/-   ##
==========================================
- Coverage   96.53%   96.51%   -0.02%     
==========================================
  Files         535      535              
  Lines       41028    41029       +1     
  Branches     6141     6141              
==========================================
- Hits        39605    39599       -6     
- Misses       1381     1387       +6     
- Partials       42       43       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kt3k
Copy link
Member

kt3k commented Dec 10, 2024

Good catch! Thanks

This mostly looks good to me, but could you also add a test case for assertNotEquals({ foo: 1 }, { foo: 1 }) to demonstrate better what we fixed?

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@kt3k kt3k merged commit 02f65f0 into denoland:main Dec 10, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

assertNotEquals assertion error message discrepancy
2 participants