jest/no-standalone-expect Correctness ​
What it does ​
Prevents expect statements outside of a test or it block. An expect within a helper function (but outside of a test or it block) will not trigger this rule.
Statements like expect.hasAssertions() will NOT trigger this rule since these calls will execute if they are not in a test block.
Example ​
javascript
describe("a test", () => {
expect(1).toBe(1);
});How to use ​
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny jest/no-standalone-expect --jest-pluginjson
{
"plugins": ["jest"],
"rules": {
"jest/no-standalone-expect": "error"
}
}