jest/no-done-callback
eslint-plugin-jest
SuggestionRecommended
eslint.config.js
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-done-callback": "error",
},
},
];test('the data is peanut butter', done => {
function callback(data) {
try {
expect(data).toBe('peanut butter');
done();
} catch (error) {
done(error);
}
}
fetchData(callback);
});beforeEach(done => {
// ...
});
test('myFunction()', done => {
// ...
});
test('myFunction()', function (done) {
// ...
});The documentation shows no correct example for this rule.
Examples from the Oxlint documentation.
jest/no-done-callback
eslint-plugin-jest
import jest from "eslint-plugin-jest";
export default [
{
plugins: { jest },
rules: {
"jest/no-done-callback": "error",
},
},
];jest/no-done-callback
jest plugin · style
{
"plugins": [
"jest"
],
"rules": {
"jest/no-done-callback": "error"
}
}style/noDoneCallback
style · since 1.6.1
{
"linter": {
"rules": {
"style": {
"noDoneCallback": "error"
}
}
}
}Disallow using a callback in asynchronous tests and hooks
Disallow calling expect conditionally
Enforce assertion to be made in a test body
Disallow using expect outside of it or test blocks