For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/jest/no-done-callback.md.
close

no-done-callback

Added in v0.5.2

Configuration

PresetConfigured Value
✅ jestPlugin.configs.all"error"
✅ jestPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, jestPlugin } from '@rslint/core';

export default defineConfig([
  jestPlugin.configs.recommended,
  {
    rules: {
      'jest/no-done-callback': 'error',
    },
  },
]);

Rule Details

Disallow using a done-style callback in Jest tests and hooks. Returning a Promise (or using async/await) is more reliable than relying on done, which can silently pass or time out when not invoked correctly.

For non-async functions the rule reports noDoneCallback and suggests wrapping the body in new Promise(done => ...). For async functions it reports useAwaitInsteadOfCallback.

Examples of incorrect code for this rule:

beforeEach(done => {
  done();
});

test('myFunction()', done => {
  done();
});

test('myFunction()', async done => {
  await fetchData();
  done();
});

Examples of correct code for this rule:

beforeEach(() => {
  return setupUsTheBomb();
});

test('myFunction()', () => {
  expect(myFunction()).toBeTruthy();
});

test('myFunction()', async () => {
  const data = await fetchData();
  expect(data).toBe('peanut butter');
});

Original Documentation