首页 > 解决方案 > 终端错误:架构验证失败,出现以下错误:数据路径“['polyfills']”应该是数组

问题描述

我刚刚使用ng new <projectName>. 然后我通过使用ng add @cypress/schematic和更改了默认测试设置ng add @briebug/jest-schematic

package.lock以供参考:

{
  "name": "betting-app",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "cypress:open": "cypress open",
    "cypress:run": "cypress run"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~11.1.2",
    "@angular/common": "~11.1.2",
    "@angular/compiler": "~11.1.2",
    "@angular/core": "~11.1.2",
    "@angular/forms": "~11.1.2",
    "@angular/platform-browser": "~11.1.2",
    "@angular/platform-browser-dynamic": "~11.1.2",
    "@angular/router": "~11.1.2",
    "@briebug/jest-schematic": "^3.1.0",
    "rxjs": "~6.6.0",
    "tslib": "^2.0.0",
    "zone.js": "~0.11.3"
  },
  "devDependencies": {
    "@angular-builders/jest": "latest",
    "@angular-devkit/build-angular": "~0.1101.4",
    "@angular/cli": "~11.1.4",
    "@angular/compiler-cli": "~11.1.2",
    "@cypress/schematic": "^1.5.3",
    "@types/jasmine": "~3.6.0",
    "@types/jest": "latest",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "jest": "latest",
    "karma-coverage": "~2.0.3",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.1.2",
    "cypress": "latest"
  }
}

当我运行时,ng test我得到了上述错误,并且正在努力如何让我的测试运行。任何帮助都会很棒!提前致谢。

标签: angularjestjscypress

解决方案


我在这里通过搜索谷歌找到了答案。

为什么在使用构建器时需要polyfills输入目标? 是构建器的架构,它不包含字段。您收到此错误的原因是所有其他(非模式)字段都被视为字符串数组 (这样您就可以像传递文件名一样传递文件名)。test@angular-builders/jestpolyfillsng testjest

我的猜测是,这polyfills是 Karma builder 的剩余部分,您可以安全地删除它。唯一需要的选项是这里angular.json提到的那些 。


推荐阅读