角度7 +角度cli 7+ ng测试不起作用

时间:2018-12-04 08:51:39

标签: angular karma-jasmine karma-runner angular7 angular-cli-v7

角度7 +角度cli 7.1.0

将项目从角度5升级到7 以及何时运行     ng test

tsConfig已添加到angular.json文件中

` "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "test.js",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "apps/app/src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",`

我得到输出  Schema validation failed with the following errors: Data path "" should have required property 'tsConfig'.

我在做什么错? 预先感谢。

2 个答案:

答案 0 :(得分:2)

您的tsConfig路径错误。 将其更改为

"tsConfig": "apps/app/src/tsconfig.spec.json"

答案 1 :(得分:0)

在我的angular 7投影ng测试中正在工作。下面是我的agular.json文件测试配置。

   "test": {
      "builder": "@angular-devkit/build-angular:karma",
      "options": {
        "main": "src/test.ts",
        "karmaConfig": "./karma.conf.js",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.spec.json",
        "scripts": [
          "src/assets/jquery-3.2.1.min.js",
          "src/assets/vendor/bootstrap/js/bootstrap.min.js",
        ],
        "styles": [
          "src/assets/vendor/bootstrap/css/bootstrap.css",
        ],
        "assets": [
          "src/assets",
          "src/favicon.ico"
        ]
      }
    },