-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Clearer messages for Node assert errors #8792
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good! Could you update the changelog?
5ec8ba5
to
be3c4a1
Compare
* upstream/master: expect: Display equal values for ReturnedWith similar to CalledWith (jestjs#8791) Clearer messages for Node assert errors (jestjs#8792) use babel-plugin-replace-ts-export-assignment package (jestjs#8805) jest-matcher-utils: Add color options to matcherHint (jestjs#8795) chore: Make sure copyright header comment includes license (jestjs#8783)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
When a test throws an AssertionError from Node's
assert
module, Jest tries to use the information in that exception to display a more informative error message.However, for errors thrown by
assert(condition)
orassert.ok(condition)
, the extra output is confusing because it starts by referring toassert.equal(received, expected)
, which makes the failure harder to understand.This PR tries to detect when the exception was probably thrown by a plain
assert
orassert.ok
call, and simplifies the enhanced output in that case, so that it is easier for the user to understand what actually caused the test to fail.Test plan
The existing output is already covered by
e2e/__tests__/failures.test.ts
, so this PR updates the corresponding snapshot.