需要包:

1
2
3
mocha
typescript
ts-node

mocha命令额外的选项:

1
--require ts-node/register

mocha不会检查tsconfig.json,需要使用环境变量手动指定compilerOptions,例如:

1
2
3
4
5
6
7
8
TS_NODE_COMPILER_OPTIONS={
"target": "es5",
"lib": ["es2015","es6"],
"downlevelIteration": true,
"sourceMap": true,
"declaration": true,
"experimentalDecorators": true
}