no-standalone-expect
Configuration
rslint.config.ts
Rule Details
Disallow using expect outside of it or test blocks. This rule reports expect calls that sit directly in a describe block, at module scope, or in other places where Jest will not run them as part of a test case. That helps catch assertions that look meaningful but never execute.
expect inside a helper function is allowed, even when the helper is defined outside the it/test callback, because the assertion still runs when the helper is invoked from a test. Static expect APIs such as expect.any() and expect.extend() at module scope are also allowed.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
- First argument (optional): object with
additionalTestBlockFunctionsadditionalTestBlockFunctions: array of function names that should also be treated as test blocks (for exampleeach.test).