MetaMask / MetaMask/eslint-config
Jest: Enforce use of `new Error` when testing thrown errors
- Dominant language
- JavaScript
- Stars
- 12
- Forks
- 21
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing this repository's ESLint configuration and any existing Jest-related tests, focusing on the `toThrow` matcher behavior described in the issue. Identify the rule or configuration entry that governs thrown-error assertions; done means the configuration enforces `new Error` rather than string arguments when testing thrown errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing, tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100