[Feature]: Detect unused stubs in test code
- Dominant language
- TypeScript
- Stars
- 45.5k
- Forks
- 6.7k
- Avg merge
- 17h 22m
- Merged PRs (30d)
- 24
Description
### 🚀 Feature Proposal
As described in [this article](https://www.baeldung.com/mockito-unnecessary-stubbing-exception), JUnit and Mockito support detecting unnecessary stubs and tell the user to remove them. It would be great to have that feature in Jest.
### Motivation
Removing unused stubs makes the test code cleaner and more maintainable.
### Example
_No response_
### Pitch
Removing unused stubs makes the test code cleaner and more maintainable. This leads to users writing cleaner and more delightful tests and prevents certain errors from happening when users expect their stubs to be responsible for a specific behavior when actually they have never been called.
Contributor guide
Research direction
No files, tests, or entry points are named in the issue. Start by reviewing Jest's existing mocking and test infrastructure, then clarify the intended unused-stub detection behavior and reporting before implementation. Done should include the agreed feature and tests covering unused stubs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100