我如何命名我的文件?我如何运行单测?
What do I name my files? How do I run a single test?
开个玩笑,给一个文件命名thing.jest.ts
。然后,您可以 运行 jest thing.jest.ts
或将开玩笑指向测试文件的文件夹,例如 jest some_folder/sub_folder
.
如何使用 AVA 执行此操作?
不起作用的东西:
- 不能使用通配符
$ ava /**/*.test.ts
✖ /**/*.test.ts does not exist.
- 不能直接指向一个文件...也许 typescript 不工作
$ ava ./src/Derivations/Sources/__tests/Source.test.ts
- 不能 运行 与 ts-node
$ ts-node ./src/Derivations/Sources/__tests/Source.test.ts
Test files must be run with the AVA CLI:
$ ava src/Derivations/Sources/__tests/Source.test.ts
这只需要一些配置。不过默认情况下,AVA 目前(2020 年 1 月)不支持 Typescript 文件。
https://github.com/avajs/ava/blob/master/docs/recipes/typescript.md
You can configure AVA to recognize TypeScript files. Then, with ts-node installed (npm i ts-node --save-dev
), you can compile them on the fly.
package.json:
{
"ava": {
"compileEnhancements": false,
"extensions": [
"ts"
],
"require": [
"ts-node/register"
]
}
}
开个玩笑,给一个文件命名thing.jest.ts
。然后,您可以 运行 jest thing.jest.ts
或将开玩笑指向测试文件的文件夹,例如 jest some_folder/sub_folder
.
如何使用 AVA 执行此操作?
不起作用的东西:
- 不能使用通配符
$ ava /**/*.test.ts
✖ /**/*.test.ts does not exist.
- 不能直接指向一个文件...也许 typescript 不工作
$ ava ./src/Derivations/Sources/__tests/Source.test.ts
- 不能 运行 与 ts-node
$ ts-node ./src/Derivations/Sources/__tests/Source.test.ts
Test files must be run with the AVA CLI:
$ ava src/Derivations/Sources/__tests/Source.test.ts
这只需要一些配置。不过默认情况下,AVA 目前(2020 年 1 月)不支持 Typescript 文件。
https://github.com/avajs/ava/blob/master/docs/recipes/typescript.md
You can configure AVA to recognize TypeScript files. Then, with ts-node installed (
npm i ts-node --save-dev
), you can compile them on the fly.package.json:
{ "ava": { "compileEnhancements": false, "extensions": [ "ts" ], "require": [ "ts-node/register" ] } }