Skip to content

noDoneCallback (since v1.6.1)

Diagnostic Category: lint/nursery/noDoneCallback

Sources:

Disallow using a callback in asynchronous tests and hooks.

This rule checks the function parameter of hooks & tests for use of the done argument, suggesting you return a promise instead.

beforeEach(done => {
// ...
});
nursery/noDoneCallback.js:1:12 lint/nursery/noDoneCallback ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Disallow using a callback in asynchronous tests and hooks.
  
  > 1 │ beforeEach(done => {
              ^^^^
    2 │     // ...
    3 │ });
  
   Return a Promise instead of relying on callback parameter.
  
test('myFunction()', done => {
// ...
});
nursery/noDoneCallback.js:1:22 lint/nursery/noDoneCallback ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

   Disallow using a callback in asynchronous tests and hooks.
  
  > 1 │ test('myFunction()', done => {
                        ^^^^
    2 │     // ...
    3 │ });
  
   Return a Promise instead of relying on callback parameter.
  
beforeEach(async () => {
// ...
});
test('myFunction()', () => {
expect(myFunction()).toBeTruthy();
});