角度cli 6,ng测试不起作用

时间:2018-05-10 12:40:46

标签: angular angular-cli angular6

我刚刚将角度项目更新为角度6。

ng build和ng提供服务,但当我使用命令运行我的测试时:

ng test

我得到了输出:

Schema validation failed with the following errors:
Data path "" should have required property 'tsConfig'.

tsconfig.json:

{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
  "es2016",
  "dom"
],
"mapRoot": "./",
"module": "es2015",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
  "../node_modules/@types"
]
}
}

我做错了什么?

3 个答案:

答案 0 :(得分:27)

我解决了。不知何故,当我将项目升级到Angular 6时,tsConfig密钥在测试中丢失了 - > angular.json中的选项。

答案 1 :(得分:13)

对我来说

  1. 在文件中:angular.json

  2. 在json节点路径处:projects-> {{yourProjectName}}-> architect-> test-> options

  3. 添加节点:“ tsConfig”:“ src / tsconfig.json”

答案 2 :(得分:0)

我遇到了这个问题,但事实证明是由于 polyfills.ts 被添加到了 tsconfig.spec.json 中, Polyfills正在导入core-js / es7 / reflect,我也在 src / test.ts 中进行了同样的操作,从src / test.ts中删除了导入,解决了我的问题

相关问题