是否可以排除仅用于构建的所有测试文件,但将它们与 nodemon 一起使用以在本地运行测试?当我排除测试文件时tsconfig.json
在我的例子中,我收到一个打字稿错误,它找不到像 jest 这样的测试库的类型。
Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.ts(2582)
{
"compilerOptions": {},
"exclude": [
"**/*.test.ts"
]
}
我想知道,因为我猜临时转译被放入了构建文件夹之外的另一个文件夹中。
一种可能的解决方案是使用两个不同的 tsconfig 文件,一个用于测试,一个用于生产构建。
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "./build",
"baseUrl": ".",
"paths": {
"*": ["types/*"]
},
"strict": true,
}
}
tsconfig.prod.json
{
"extends": "./tsconfig",
"exclude": ["**/*.test.ts", "**/*.mock.ts"]
}
然后运行时将 tsc 指向新配置tsc -p tsconfig.prod.json
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)