【发布时间】:2020-05-27 00:38:45
【问题描述】:
我为 Nestjs 和微服务构建了一个样板(仍在进行中)
现在我遇到了一个问题,我尝试运行应用程序或运行测试,它给了我这个
位于github link的代码 我在 tsconfig.json 上添加路径的问题
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist/apps",
"baseUrl": "./",
"incremental": true,
"paths": {
"@frontapi/*": ["./apps/front-api/src/*"],
"@config/*": ["./apps/config-server/src/*"],
"@entities/*": ["./apps/entities-server/src/*"],
"@devops/*": ["./apps/devops-mcu/src/*"],
"@tasks/*": ["./apps/task-que-handler/src/*"],
"@logicBus/*": ["./apps/logic-bus/src/*"],
"@common/*": ["./apps/common/*"]
}
},
"exclude": [
"node_modules",
"dist"
]
}
然后我运行 json 包进行测试的两个命令: "start:frontapi": "npm run start:frontapi:env && tsc-watch -p tsconfig.build.json --onSuccess \"node -r tsconfig-paths/register -r ts-node/register --inspect-brk =5858 dist/front-api/src/main.js\"",
和 "test:e2e": "npm run clean&&tsc -p tsconfig.build.json && jest --config ./apps/front-api/test/jest-e2e.json",
两者都告诉我它不在@common/config/configuration 我不知道我在这里缺少什么并帮助解决这个问题
编辑他的内容有一个名为 jest-e2e.json 的文件
{
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": ".",
"testEnvironment": "node",
"testRegex": ".e2e-spec.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"moduleNameMapper": {
"^@frontapi/(.*)$": "./apps/front-api/src/$1",
"^@config/(.*)$": "./apps/config-server/src/$1",
"^@entities/(.*)$": "./apps/entities-server/src/$1",
"^@devops/(.*)$": "./apps/devops-mcu/src/$1",
"^@tasks/(.*)$": "./apps/task-que-handler/src/$1",
"^@logicBus/(.*)$": "./apps/logic-bus/src/$1",
"^@common/(.*)$": "./apps/common/$1"
}
}
如果我在这里遗漏了什么,或者您遗漏了什么,请告诉我,我会尽力提供
【问题讨论】:
-
您的路径是否已映射到您的
jest.e2e.json配置中? -
@JayMcDoniel yap 只是编辑帖子显示它的内容
标签: node.js typescript express jestjs nestjs