prefer-ending-with-an-expect
UnreleasedConfiguration
Rule Details
Prefer ending a test body with an assertion. A test whose last statement is not
an expect (or another configured assert function) often indicates unfinished
work that may pass silently.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
assertFunctionNames
Names of functions treated as assertions. Patterns follow
eslint-plugin-jest:
* matches a dot-separated segment; ** matches zero or more segments. Default
is ["expect"]. Special regex characters in names may need escaping (for
example expect\\$).
Examples of incorrect code with { "assertFunctionNames": ["expect"] }:
Examples of correct code with
{ "assertFunctionNames": ["expect", "expectSaga"] }:
Examples of correct code for SuperTest
with { "assertFunctionNames": ["expect", "request.**.expect"] }:
additionalTestBlockFunctions
Extra function names treated like test / it wrappers so their callbacks are
also required to end with an assertion.
Examples of correct code with
{ "additionalTestBlockFunctions": ["each.test"] }: