【问题标题】:Angular: after moving from Karma to Jest, Error "Unrecognized CLI Parameters"Angular:从 Karma 移动到 Jest 后,出现错误“无法识别的 CLI 参数”
【发布时间】:2019-04-30 08:49:19
【问题描述】:

我将我的项目从 Angular 6.4 更新到 Angular 7.1,现在运行脚本:ng test app-name --coverage 给了我错误:

● Unrecognized CLI Parameters:

  Following options were not recognized:
  ["main", "polyfills", "tsConfig"]

  CLI Options Documentation:
  https://jestjs.io/docs/en/cli.html

angular.json 中测试命令的配置如下:

"test": {
  "builder": "@angular-builders/jest:run",
  "options": {
    "main": "apps/app-name/src/test.ts",
    "polyfills": "apps/app-name/src/polyfills.ts",
    "tsConfig": "apps/app-name/tsconfig.spec.json",
    "configPath": "./jest.config.json",
    "styles": [
      "apps/app-name/src/styles.scss"
    ],
    "scripts": [],
    "assets": [
      "apps/app-name/src/favicon.ico",
      "apps/app-name/src/assets"
    ]
  }
},

我应该如何更新配置以与 Angular 7 兼容?

【问题讨论】:

  • 在运行测试时尝试使用--code-coverage 而不是--coverage
  • @R.Richards 这样我得到:Unknown option: '--code-coverage'。我不认为该错误与覆盖标志有关。即使没有它,我也会遇到同样的错误。
  • 如果你只运行ng test,单元测试会运行吗?没有其他参数。
  • @R.Richards 不,它没有

标签: angular jestjs jest-preset-angular


【解决方案1】:

错误是我在迁移到 Jest 时忘记删除/替换旧的 karma-builder 配置。

显然 Angular 7 比 Angular 6 更好地检查了类似的东西(万岁!),所以我把它误认为是 Angular 或 Jest 错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-28
    • 2021-07-16
    • 2018-11-21
    • 1970-01-01
    • 1970-01-01
    • 2015-07-31
    相关资源
    最近更新 更多