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: README.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
3
3
Adds rudimentary [TypeScript](https://www.typescriptlang.org/) support to [AVA](https://avajs.dev).
4
4
5
-
This is designed to work for projects that precompile their TypeScript code, including tests. It allows AVA to load the resulting JavaScript, while configuring AVA to use the TypeScript paths.
5
+
This is designed to work for projects that precompile TypeScript. It allows AVA to load the compiled JavaScript, while configuring AVA to treat the TypeScript files as test files.
6
6
7
-
In other words, say you have a test file at `src/test.ts`. You've configured TypeScript to output to `build/`. Using `@ava/typescript` you can run the `build/test.js` file using `npx ava src/test.ts`. AVA won't pick up any of the JavaScript files present in the `build/` directory, unless they have a TypeScript counterpart in `src/`.
7
+
In other words, say you have a test file at `src/test.ts`. You've configured TypeScript to output to `build/`. Using `@ava/typescript` you can run the testusing `npx ava src/test.ts`.
8
8
9
9
## Enabling TypeScript support
10
10
@@ -24,13 +24,15 @@ Then, enable TypeScript support either in `package.json` or `ava.config.*`:
24
24
"typescript": {
25
25
"rewritePaths": {
26
26
"src/": "build/"
27
-
}
27
+
},
28
+
"compile": true
28
29
}
29
30
}
30
31
}
31
32
```
32
33
33
-
Both keys and values of the `rewritePaths` object must end with a `/`. Paths are relative to your project directory.
34
+
Both keys and values of the `rewritePaths` object must end with a `/`. Paths are relative to your project directory.\
35
+
You can enable compilation via the `compile` property. It is recommended to set it to `false` when running `ts` in a watcher mode.
34
36
35
37
Output files are expected to have the `.js` extension.
test('main() config validation: throw when config is not a plain object',withProvider,(t,provider)=>{
32
14
validateConfig(t,provider,false);
@@ -35,7 +17,7 @@ test('main() config validation: throw when config is not a plain object', withPr
35
17
validateConfig(t,provider,[]);
36
18
});
37
19
38
-
test('main() config validation: throw when config contains keys other than \'extensions\'or \'rewritePaths\'',withProvider,(t,provider)=>{
20
+
test('main() config validation: throw when config contains keys other than \'extensions\', \'rewritePaths\' or \'compile\'',withProvider,(t,provider)=>{
39
21
validateConfig(t,provider,{foo: 1});
40
22
});
41
23
@@ -55,47 +37,26 @@ test('main() config validation: config may not be an empty object', withProvider
55
37
validateConfig(t,provider,{});
56
38
});
57
39
40
+
test('main() config validation: throw when config.compile is not a boolean',withProvider,(t,provider)=>{
0 commit comments