expect-expect
Added in v0.8.1Configuration
Rule Details
Enforce that every Rstest test registration contains at least one assertion. A test with no assertion can pass without verifying anything, hiding the fact that its intent was never checked.
Examples of incorrect code:
Examples of correct code:
test.todo / it.todo have no callback and are exempt:
The rule recognizes Rstest test registrations from globals, @rstest/core
imports and aliases, require, namespace access, import.meta.rstest,
test.extend(...), .each / .for, and @rstest/playwright. describe and
lifecycle hooks are not test registrations and are never required to assert.
Named function declarations and variable functions are resolved independently
of whether they appear before or after the test registration.
Options
assertFunctionNames
Names of functions treated as assertions. Defaults to ["expect", "assert"],
matching the two assertion entry points Rstest exposes as globals. Names support
wildcards: request.*.expect, request.**.expect, expect*.
Rstest's own expect counts whatever the callee looks like, so these names only
need to cover assertion helpers the rule cannot resolve — a wrapper of your own,
or a third-party assertion library. context.expect(...), rstest.expect(...),
an aliased import { expect as check } and import.meta.rstest.expect(...) are
all recognized without configuration.
The list replaces the default rather than extending it, so name assert again if
you still want it. Naming your own helpers cannot switch Rstest's expect off
though — it is recognized whether or not the list mentions it, unlike in
eslint-plugin-jest, where dropping expect from the list stops it counting.
additionalTestBlockFunctions
Additional function names to treat as test blocks.
The rule provides no automatic fix.