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/recipes/typescript.md
+38-7Lines changed: 38 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,13 +28,44 @@ There are two components to a setup like this:
28
28
29
29
```json
30
30
"ava": {
31
-
"extensions": {
32
-
"ts": "module"
33
-
},
34
-
"nodeArguments": [
35
-
"--loader=tsx"
36
-
]
37
-
}
31
+
"extensions": {
32
+
"ts": "module"
33
+
},
34
+
"nodeArguments": [
35
+
"--loader=tsx"
36
+
]
37
+
}
38
+
```
39
+
### When using custom loaders
40
+
41
+
#### Mocking
42
+
43
+
Mocking with `tsx` (such as with [`esmock`](https://github.com/iambumblehead/esmock)) isn't currently possible (https://github.com/esbuild-kit/tsx/issues/264). [`ts-node`](https://github.com/TypeStrong/ts-node) can be used instead:
44
+
45
+
`package.json`:
46
+
47
+
```json
48
+
"ava": {
49
+
"extensions": {
50
+
"ts": "module"
51
+
},
52
+
"nodeArguments": [
53
+
"--loader=ts-node/esm",
54
+
"--loader=esmock"
55
+
]
56
+
}
57
+
```
58
+
59
+
#### Node.js 20
60
+
61
+
In Node.js 20, custom loaders must be specified via the `NODE_OPTIONS` environment variable:
0 commit comments