Cypress error: `cy.task('coverageReport')` failed - Cannot read properties of undefined (reading 'start')

オープン
#602 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
cypress, typescript
領域
testing

調査の方向性

リンクされた imagelightbox のコミットで失敗を再現することから始め、generateReport の support.js、.nyc_output/out.json のデータ、およびログに記載された NYC/istanbul のスタックエントリを調査します。Cypress after-all の coverageReport task のパスを確認します。Spec が完了し、coverage reporting が undefined start error なしで lcov 出力を生成すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Logs and screenshots
Hi,
I get the following error in cypress (this is the output from "Print to console"):

CypressError: `cy.task('coverageReport')` failed with the following error:

> Cannot read properties of undefined (reading 'start')

Because this error occurred during a `after all` hook we are skipping all of the remaining tests.
    at ../driver/src/cy/commands/task.ts/__webpack_exports__.default/task (http://localhost:8080/__cypress/runner/cypress_runner.js:145775:78)
From previous event:
    at task (http://localhost:8080/__cypress/runner/cypress_runner.js:145757:10)
    at ../driver/src/cypress/cy.ts/addCommand/wrap (http://localhost:8080/__cypress/runner/cypress_runner.js:157372:43)
From Your Spec Code:
    at generateReport (webpack:///./node_modules/@cypress/code-coverage/support.js:200:0)
    at ../driver/src/cypress/cy.ts/setRunnable/runnable.fn (http://localhost:8080/__cypress/runner/cypress_runner.js:157640:43)
    at callFn (http://localhost:8080/__cypress/runner/cypress_runner.js:107910:21)
    at ../driver/node_modules/mocha/lib/runnable.js/</Runnable.prototype.run (http://localhost:8080/__cypress/runner/cypress_runner.js:107897:13)
    at ../driver/src/cypress/runner.ts/create/onRunnableRun (http://localhost:8080/__cypress/runner/cypress_runner.js:164958:30)
    at finallyHandler (http://localhost:8080/__cypress/runner/cypress_runner.js:7872:23)
    at tryCatcher (http://localhost:8080/__cypress/runner/cypress_runner.js:11318:23)
    at ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromiseFromHandler (http://localhost:8080/__cypress/runner/cypress_runner.js:9253:31)
    at ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromise (http://localhost:8080/__cypress/runner/cypress_runner.js:9310:18)
    at ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromise0 (http://localhost:8080/__cypress/runner/cypress_runner.js:9355:10)
    at ../../node_modules/bluebird/js/release/promise.js/</module.exports/Promise.prototype._settlePromises (http://localhost:8080/__cypress/runner/cypress_runner.js:9435:18)
    at _drainQueueStep (http://localhost:8080/__cypress/runner/cypress_runner.js:6025:12)
    at _drainQueue (http://localhost:8080/__cypress/runner/cypress_runner.js:6018:24)
    at ../../node_modules/bluebird/js/release/async.js/</Async.prototype._drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:6034:16)
    at ../../node_modules/bluebird/js/release/async.js/</Async/this.drainQueues (http://localhost:8080/__cypress/runner/cypress_runner.js:5904:14)


From Node.js Internals:
  TypeError: Cannot read properties of undefined (reading 'start')
      at <unknown> (/home/user/project/node_modules/istanbul-reports/lib/lcovonly/index.js:59:43)
  at Array.forEach (<anonymous>)
      at LcovOnlyReport.onDetail (/home/user/project/node_modules/istanbul-reports/lib/lcovonly/index.js:56:34)
      at LcovReport.<computed> [as onDetail] (/home/user/project/node_modules/istanbul-reports/lib/lcov/index.js:25:23)
      at Visitor.value (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:38:38)
      at ReportNode.visit (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:88:21)
      at <unknown> (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:92:19)
  at Array.forEach (<anonymous>)
      at ReportNode.visit (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:91:28)
      at <unknown> (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:92:19)
  at Array.forEach (<anonymous>)
      at ReportNode.visit (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:91:28)
      at ReportTree.visit (/home/user/project/node_modules/istanbul-lib-report/lib/tree.js:127:24)
      at LcovReport.execute (/home/user/project/node_modules/istanbul-lib-report/lib/report-base.js:12:44)
      at <unknown> (/home/user/project/node_modules/nyc/index.js:467:10)
  at Array.forEach (<anonymous>)
      at NYC.report (/home/user/project/node_modules/nyc/index.js:461:19) [index.ce8ed54d.js:99335:13](http://localhost:8080/__/assets/index.ce8ed54d.js)

Versions

  • What is this plugin's version? 3.10.0
  • What is Cypress version? 10.10.0
  • What is your operating system? Debian testing
  • What is the shell? zsh
  • What is the Node version? v18.11.0
  • What is the NPM version? 8.19.2
  • How do you instrument your application? gulp-istanbul
  • When running tests, if you open the web application in regular browser, and open DevTools, do you see window.__coverage__ object? Yes

image

  • Is there .nyc_output folder? Is there .nyc_output/out.json file. Is it empty? Can you paste at least part of it so we can see the keys and file paths?

There is, pasting out.json:

{
  "/home/user/project/src/file.js": {
    "path": "/home/user/project",
    "s": {
      "1": 1,
      "2": 1,
      "3": 1
      "...": "truncated"
    }
  }
}
  • Do you have any custom NYC settings in package.json (nyc object) or in other NYC config files No
  • Do you run Cypress tests in a Docker container? No

Describe the bug
When running a spec file, I get the error reported above.

Link to the repo
https://github.com/marekdedic/imagelightbox/commit/36513ec34716c92046bec270979108b5e3a23111

主要言語
TypeScript
スター
440
フォーク
114
平均マージ
42分
マージ済み PR(30日)
19

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

cypress-io/code-coverage のほかの issue

cypress-io/code-coverage の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。