noDoneCallback
Este conteúdo não está disponível em sua língua ainda.
Diagnostic Category: lint/style/noDoneCallback
Since: v1.6.1
Sources:
- Same as:
jest/no-done-callback
Description
Section titled DescriptionDisallow 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.
Examples
Section titled ExamplesInvalid
Section titled InvalidbeforeEach((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.
Valid
Section titled ValidbeforeEach(async () => { // ...});
test('test-name', () => { expect(myFunction()).toBeTruthy();});
How to configure
Section titled How to configure{ "linter": { "rules": { "style": { "noDoneCallback": "error" } } }}