Skip to content

jest/valid-expect Correctness

What it does

This rule triggers a warning if expect() is called with more than one argument or without arguments. It would also issue a warning if there is nothing called on expect(), e.g.:

Example

javascript
expect();
expect("something");
expect(true).toBeDefined;
expect(Promise.resolve("Hi!")).resolves.toBe("Hi!");

This rule is compatible with eslint-plugin-vitest, to use it, add the following configuration to your .eslintrc.json:

json
{
  "rules": {
    "vitest/valid-expect": "error"
  }
}

References

Released under the MIT License.