-
Notifications
You must be signed in to change notification settings - Fork 230
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
[new rule] Require that TypeScript tests use a typed jest.mock factory #1313
Labels
Comments
This sounds ok, and won't require type-checking, just |
🎉 This issue has been resolved in version 27.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A new rule that requires type-checking.
jest.mock
andjest.doMock
take an optional generic, representing the return type of the factory. For example,Without specifying
typeof import('../moduleName')
, Jest's types doesn't know what the module looks like and will allow anything to be returned in the factory.I'd like to have an ESLint rule to enforce that the generic parameter is used whenever a factory function is used. Jest auto-mocks (no factory) and virtual mocks (no corresponding actual module) don't need to have the generic parameter.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Auto-fixable: Yes
The text was updated successfully, but these errors were encountered: