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/02-execution-context.md
+25-1
Original file line number
Diff line number
Diff line change
@@ -40,12 +40,36 @@ Plan how many assertion there are in the test. The test will fail if the actual
40
40
41
41
## `t.teardown(fn)`
42
42
43
-
Registers the `fn` function to be run after the test has finished. You can register multiple functions and they'll run in order. You can use asynchronous functions: only one will run at a time.
43
+
Registers the `fn` function to be run after the test has finished. You can register multiple functions and they'll run in order<sup>†</sup>. You can use asynchronous functions: only one will run at a time.
44
44
45
45
You cannot perform assertions using the `t` object or register additional functions from inside `fn`.
46
46
47
47
You cannot use `t.teardown()` in hooks either.
48
48
49
+
<sup>†</sup> In the next major release we'll change this so teardown functions run in reverse order. The last registered function will be called first. You can opt in to this behavior now by enabling the `reverseTeardowns` experiment.
50
+
51
+
**`package.json`**:
52
+
53
+
```json
54
+
{
55
+
"ava": {
56
+
"nonSemVerExperiments": {
57
+
"reverseTeardowns": true
58
+
}
59
+
}
60
+
}
61
+
```
62
+
63
+
**`ava.config.js`**:
64
+
65
+
```js
66
+
exportdefault {
67
+
nonSemVerExperiments: {
68
+
reverseTeardowns:true
69
+
}
70
+
}
71
+
```
72
+
49
73
## `t.timeout(ms)`
50
74
51
75
Set a timeout for the test, in milliseconds. The test will fail if this timeout is exceeded. The timeout is reset each time an assertion is made.
0 commit comments