expect-expect
Added in v0.6.0Configuration
Rule Details
Ensure every Jest test callback contains at least one assertion. The rule tracks test APIs such as test, it, fit, xit, and xtest (including chained forms like it.each that the Jest integration recognizes) and reports when none of the configured assertion callee patterns appear in the body. Assertions inside a named function declaration or variable function passed as the test callback are attributed to every test that references it, regardless of whether the callback is declared before or after the registration. This guards against tests that run side effects but never verify outcomes.
Skipped test.todo / it.todo bodies are ignored.
Divergence from eslint-plugin-jest
When a callback is passed by reference, this rule resolves its declaration and counts the assertions found there, wherever that declaration sits:
Upstream eslint-plugin-jest reports Test has no assertions here, because it clears a registration only when the registration was already seen at the time the assertion was walked. The declaration is hoisted, so this is the same program as the call-first form it('should pass', myTest); function myTest() { ... } that both rules accept, and reporting one but not the other is an order-dependent false positive.
Callbacks declared with const or var are resolved the same way, which upstream does not do at all — it only ever looks at function declarations, so it reports those tests in either order.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
assertFunctionNames(default["expect"]): callee chains that count as assertions. Patterns follow eslint-plugin-jest:*matches a dot-separated segment;**matches zero or more segments. The pattern is matched case-insensitively against the full chain (for examplerequest.**.expectfor SuperTest.expect). Special regex characters in names may need escaping when mirroring ESLint behavior.additionalTestBlockFunctions: extra global function names treated liketest/itwrappers (for example helpers fromjest-theories) so their callbacks are also required to contain an assertion.
For more option examples and edge cases, see the upstream rule documentation linked below.