You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/rules/await-async-utils.md
+29-9
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,26 @@
1
-
# Enforce async utils to be awaited properly (await-async-utils)
1
+
# Enforce promises from async utils to be handled (await-async-utils)
2
2
3
3
Ensure that promises returned by async utils are handled properly.
4
4
5
5
## Rule Details
6
6
7
7
Testing library provides several utilities for dealing with asynchronous code. These are useful to wait for an element until certain criteria or situation happens. The available async utils are:
8
8
9
-
-`waitFor`_(introduced in dom-testing-library v7)_
9
+
-`waitFor`_(introduced since dom-testing-library v7)_
This rule aims to prevent users from forgetting to handle the returned promise from those async utils, which could lead to unexpected errors in the tests execution. The promises can be handled by using either `await` operator or `then` method.
15
+
This rule aims to prevent users from forgetting to handle the returned
16
+
promise from async utils, which could lead to
17
+
problems in the tests. The promise will be considered as handled when:
18
+
19
+
- using the `await` operator
20
+
- wrapped within `Promise.all` or `Promise.allSettled` methods
21
+
- chaining the `then` method
22
+
- chaining `resolves` or `rejects` from jest
23
+
- it's returned from a function (in this case, that particular function will be analyzed by this rule too)
0 commit comments