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

Jest: Enforce use of new Error when testing thrown errors #327

Open
mcmire opened this issue Oct 21, 2023 · 1 comment
Open

Jest: Enforce use of new Error when testing thrown errors #327

mcmire opened this issue Oct 21, 2023 · 1 comment

Comments

@mcmire
Copy link
Contributor

mcmire commented Oct 21, 2023

The toThrow matcher can take either a string or an Error object. If given a string, it tests that if there is a thrown error, the error message includes the given string; if given an Error, however, it tests that the thrown error message completely matches the given error message. In general, the complete message of an error should be tested, not just part of it, because error messages are part of user experience and it's important to verify that the user is seeing the right thing.

@mcmire
Copy link
Contributor Author

mcmire commented Feb 8, 2024

We should implement this in core first before adding it to this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant