jest/expect-expect Correctness ​
What it does ​
This rule triggers when there is no call made to expect in a test, ensure that there is at least one expect call made in a test.
Why is this bad? ​
People may forget to add assertions.
Examples ​
Examples of incorrect code for this rule:
it("should be a test", () => {
console.log("no assertion");
});
test("should assert something", () => {});This rule is compatible with eslint-plugin-vitest, to use it, add the following configuration to your .eslintrc.json:
{
"rules": {
"vitest/expect-expect": "error"
}
}Configuration ​
This rule accepts a configuration object with the following properties:
additionalTestBlockFunctions ​
type: string[]
default: []
An array of function names that should also be treated as test blocks.
assertFunctionNamesJest ​
type: string[]
default: ["expect"]
A list of function names that should be treated as assertion functions.
assertFunctionNamesVitest ​
type: string[]
default: ["expect", "expectTypeOf", "assert", "assertType"]
A list of function names that should be treated as assertion functions for Vitest.
How to use ​
To enable this rule in the CLI or using the config file, you can use:
oxlint --deny jest/expect-expect --jest-plugin{
"plugins": ["jest"],
"rules": {
"jest/expect-expect": "error"
}
}