jest/expect-expect
eslint-plugin-jest
No autofixRecommended
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/expect-expect": "error",
},
},
];it('should be a test', () => {
console.log('no assertion');
});
test('should assert something', () => {});it('should be a test', () => {
expect(true).toBeDefined();
});
it('should work with callbacks/async', () => {
somePromise().then(res => expect(res).toBe('passed'));
});Examples from the ESLint documentation.
jest/expect-expect
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/expect-expect": "error",
},
},
];jest/expect-expect
jest plugin · correctness
{
"plugins": [
"jest"
],
"rules": {
"jest/expect-expect": "error"
}
}suspicious/useExpect
suspicious · since 2.4.2
{
"linter": {
"rules": {
"suspicious": {
"useExpect": "error"
}
}
}
}Enforce having expectation in test body
Disallow calling expect conditionally
Disallow using a callback in asynchronous tests and hooks
Disallow using expect outside of it or test blocks