在 angular 中从量角器迁移到赛普拉斯给出错误

Migrating from protractor to cypress in angular giving error

我正在尝试将 Protractor e2e 测试迁移到 cypress。第一步是 运行 这个命令:ng add @cypress/schematic 一切顺利,但现在当我输入 ng e2e 时出现错误:

An unhandled exception occurred: Job name "..getProjectMetadata" does not exist. See "C:\Users\WAEL~1.ABB\AppData\Local\Temp\ng-Nojsrx\angular-errors.log" for further details.

我正在使用 angular8, "@angular-devkit/build-angular": "0.803.24" 我尝试了 devkit 的所有其他次要版本,但仍然出现相同的错误。有什么线索吗?

angular.json:

"e2e": {
  "builder": "@cypress/schematic:cypress",
  "options": {
    "devServerTarget": "proj:serve",
    "watch": true,
    "headless": false
  },
  "configurations": {
  "production": {
    "devServerTarget": "proj:serve:production"
  }
}

错误日志:

[error] Error: Job name "..getProjectMetadata" does not exist. at Observable._subscribe (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\src\experimental\jobs\simple-scheduler.js:350:23) at Observable._trySubscribe (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\Observable.js:44:25) at Observable.subscribe (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\Observable.js:30:22) at C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\util\subscribeTo.js:22:31 at Object.subscribeToResult (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\util\subscribeToResult.js:10:45) at SwitchMapSubscriber._innerSub (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\operators\switchMap.js:65:54) at SwitchMapSubscriber._next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\operators\switchMap.js:55:14) at SwitchMapSubscriber.Subscriber.next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\Subscriber.js:66:18) at SwitchMapSubscriber.notifyNext (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\operators\switchMap.js:86:26) at InnerSubscriber._next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\InnerSubscriber.js:28:21) at InnerSubscriber.Subscriber.next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\Subscriber.js:66:18) at C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\util\subscribeTo.js:17:28 at Object.subscribeToResult (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\util\subscribeToResult.js:10:45) at SwitchMapSubscriber._innerSub (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\operators\switchMap.js:65:54) at SwitchMapSubscriber._next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\operators\switchMap.js:55:14) at SwitchMapSubscriber.Subscriber.next (C:\work\proj-Branches\wip3\proj\node_modules@angular-devkit\core\node_modules\rxjs\internal\Subscriber.js:66:18)

这看起来像是版本控制问题。

您有 angular8 的标签,这是您 运行 正在使用的版本吗?我注意到 Angular 不再支持 v8 和更低版本。

另外 @cypress/schematic 是今年发布的,可能不兼容。


我测试了 Angular 8 starter app + @cypress/schematic,并尝试 运行 ng e2e 给出了同样的错误。

但是,运行宁“标准”赛普拉斯命令

yarn cypress open

or

npx cypress open

将打开 Cypress 运行ner 并在 /cypress/integration 运行 下进行测试。

此外,手动启动 Angular 开发服务器 - ng start 以便可以在 http://localhost:4200.

访问该应用程序