prefer-jest-mocked
Configuration
rslint.config.ts
Rule Details
Prefer jest.mocked() over type assertions such as fn as jest.Mock when
working with mocked functions in Jest. The jest.mocked() helper preserves
correct mock typings without manual casts, which improves type safety and keeps
mock setup easier to read.
This rule reports type assertions and angle-bracket casts to Jest mock types,
including chained assertions like as unknown as jest.Mock. It is fixable.
Restricted types:
jest.Mockjest.MockedFunctionjest.MockedClassjest.MockedObject
Examples of incorrect code for this rule:
Examples of correct code for this rule: