跳转到内容

noDoneCallback

Diagnostic Category: lint/style/noDoneCallback

Since: v1.6.1 Sources:

Disallow using a callback in asynchronous tests and hooks.

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

beforeEach((done) => {
// ...
});
code-block.js:1:13 lint/style/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('tets-name', (done) => {
// ...
});
code-block.js:1:20 lint/style/noDoneCallback ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Disallow using a callback in asynchronous tests and hooks.

> 1 │ test(‘tets-name’, (done) => {
^^^^
2 │ // …
3 │ });

Return a Promise instead of relying on callback parameter.

beforeEach(async () => {
// ...
});
test('test-name', () => {
expect(myFunction()).toBeTruthy();
});