jestjs/jest

[Feature]: Detect unused stubs in test code

Open

#12,296 opened on Feb 3, 2022

View on GitHub
 (13 comments) (10 reactions) (0 assignees)TypeScript (45,361 stars) (6,653 forks)batch import
:rocket: Feature RequestHelp WantedPinned

Description

🚀 Feature Proposal

As described in this article, 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