Mocha 在使用 TypeScript 时找不到我的测试文件
Mocha can't find my test files when using TypeScript
我在 package.json
中的 test
脚本是:
"test": "yarn seed && (nyc mocha --opts ./test/mocha.unit.opts)",
我的mocha.unit.opts
是:
--require ts-node/register
--require source-map-support/register
--require ./test/unit/helper.ts
--recursive
./test/unit/**/*.spec.ts
--exit
我的文件夹结构如下:
但是没有错误。它显示覆盖率(不知何故都是 100%)并退出:
error Command failed with exit code 1.
当我运行yarn test
我错过了什么?
我认为您没有提供足够的问题信息。可能有几个问题和解决方案:
- 检查
package.json
(您是否已正确安装所有内容)
- 检查
.spec.ts
个文件,它们能否正确编译
- 你能不能试一下运行一个测试一个测试,可能有的地方有问题
- 尝试直接通过终端 运行 mocha 而不
mocha.units.opts
file
我在 package.json
中的 test
脚本是:
"test": "yarn seed && (nyc mocha --opts ./test/mocha.unit.opts)",
我的mocha.unit.opts
是:
--require ts-node/register
--require source-map-support/register
--require ./test/unit/helper.ts
--recursive
./test/unit/**/*.spec.ts
--exit
我的文件夹结构如下:
但是没有错误。它显示覆盖率(不知何故都是 100%)并退出:
error Command failed with exit code 1.
当我运行yarn test
我错过了什么?
我认为您没有提供足够的问题信息。可能有几个问题和解决方案:
- 检查
package.json
(您是否已正确安装所有内容) - 检查
.spec.ts
个文件,它们能否正确编译 - 你能不能试一下运行一个测试一个测试,可能有的地方有问题
- 尝试直接通过终端 运行 mocha 而不
mocha.units.opts
file