我有一个很新的NestJS应用程序。我正在尝试运行单元测试,但是当使用绝对路径(“src / users / ...”)时,它们会因为“找不到模块..”而失败,但是使用相对路径(“./ users / ..”)时可以工作。这里的配置有什么问题吗?
package.json中的Jest设置:
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true
}
}