简体   繁体   English

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

[英]angular cli 6, ng test not working

I have just updated my angular project to angular 6. 我刚刚将角度项目更新为角度6。

ng build and ng serve work, but when I run my tests with the command: ng build和ng服务工作,但是当我使用命令运行我的测试时:

ng test

I get the output: 我得到输出:

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

tsconfig.json: 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"
]
}
}

What am I doing wrong ? 我究竟做错了什么 ?

I solved it. 我解决了 Somehow when I upgraded the project to Angular 6 the tsConfig key was missing under test -> options in angular.json . 不知怎的,当我升级项目,角6 tsConfig关键是缺少测试-在>选项angular.json

for me 为了我

  1. in file: angular.json 在文件中:angular.json

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

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

我是有这个问题,但它竟然是因为被添加到tsconfig.spec.json polyfills.ts,Polyfills是进口核心JS / ES7 /反映,我也做同样在src / test.ts从src / test.ts中删除导入修复了我的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM