Angular.json - 为测试设置默认配置

时间:2021-07-27 10:41:01

标签: angular karma-jasmine

我想知道是否有办法为 ng test 文件中的 angular.json 设置默认配置。

我有这棵树:

...
"projects": {
  "myProject": {
    ...
    "architect": {
      "build": {
        "builder": "@angular-devkit/build-angular:browser",
        "options": {
          ...
        },
        "configurations": {
          "production": {
            ...
          },
          "development": {
            ...
          }
        }
      },
      "serve": {
        ...
        "options": {
          "browserTarget": "myProject:build:development"
        },
      },
      "test": {
        "options": {
          "browserTarget": "myProject:build:development",
        }
      } 
    }
  }
}

所以我通过设置 servebuild:development 默认设置为 options.browserTarget,因此当我运行 ng serve 时,CLI 运行 development 配置。< /p>

现在,当我在没有任何 build:development 设置的情况下运行 ng test 时,如果明显没有 --configuration 设置,我应该怎么做才能运行 options.browserTarget?此配置为 ng test 引发此错误:

Schema validation failed with the following errors:
  Data path "" should NOT have additional properties(browserTarget).

ng build 设置默认配置的正确解决方案是什么?

0 个答案:

没有答案
相关问题