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

toThrow assertion message includes Error name, but does not match on it #6688

Closed
mullen3 opened this issue Jul 13, 2018 · 8 comments
Closed

Comments

@mullen3
Copy link

mullen3 commented Jul 13, 2018

🐛 Bug Report

Not sure if this is necessarily a bug, but definitely a footgun/confusing message. When expecting a function toThrow, jest outputs the Error name in the test failure message, but does not actually match on the name. Like this:

Expected the function to throw an error matching:
  /Name: message/
Instead, it threw:
  Name: message

To Reproduce

https://repl.it/repls/IroncladCreativeForm

Expected behavior

Either match on the name as well as the message, or strip out the name from the test failure report.

@rickhanlonii
Copy link
Member

@mullen3 thanks for reporting, this makes sense to me, what do you think @SimenB?

@SimenB
Copy link
Member

SimenB commented Nov 26, 2018

Stripping out .name makes sense, doesn't it?

@rickhanlonii
Copy link
Member

Makes sense to me, @mullen3 interested in putting in your first Jest PR?

@mullen3
Copy link
Author

mullen3 commented Nov 26, 2018

Thanks @SimenB and @rickhanlonii. Which solution do we think is better? Looks like my repro is gone now 😢and I kind of forget the exact shape of the issue. Nevermind I just forgot how to use that site.

@rickhanlonii
Copy link
Member

I think as @SimenB said we should strip out the name from the test failure report

@olivierbeaulieu
Copy link
Contributor

It seems like this issue has been resolved in #7621

@thymikee
Copy link
Collaborator

Yup, that should fix it

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants