`.nyc_output/out.json` is an empty object when using with `@cypress/react`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- babel, node.js, typescript
- 領域
- testing
調査の方向性
リンクされた再現リポジトリから始め、npm test を実行して空の .nyc_output/out.json を確認します。次に、ESM、コンポーネントテスト、インストルメンテーションの設定について、package.json、cypress/plugins/index.cjs、Cypress の設定を調べます。.nyc_output/out.json にカバレッジデータが現れ、生成されたレポートにテスト対象のファイルが含まれていれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Logs and screenshots
Please provide debug logs by running Cypress from the terminal with DEBUG=code-coverage environment variable set, see the Debugging section of the README file.
Debug logs
code-coverage reset code coverage in interactive mode +0ms
code-coverage parsed sent coverage +32ms
code-coverage wrote coverage file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json +1ms
code-coverage parsed sent coverage +25ms
code-coverage wrote coverage file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json +0ms
⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information
Did you forget to instrument your web application? Read https://github.com/cypress-io/code-coverage#instrument-your-application
code-coverage ⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information +8s
code-coverage ⚠️ file /Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output/out.json has no coverage information +1ms
code-coverage calling NYC reporter with options { 'report-dir': '/Users/chrisrzhou/Github/cypress-coverage-repo/coverage', reporter: [ 'lcov', 'clover', 'json', 'json-summary' ], extension: [ '.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx' ], excludeAfterRemap: false, 'temp-dir': '/Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output', tempDir: '/Users/chrisrzhou/Github/cypress-coverage-repo/.nyc_output', reportDir: '/Users/chrisrzhou/Github/cypress-coverage-repo/coverage' } +7ms
code-coverage current working directory is /Users/chrisrzhou/Github/cypress-coverage-repo +0ms
code-coverage after reporting, returning the report folder name /Users/chrisrzhou/Github/cypress-coverage-repo/coverage +40ms
code-coverage Final coverage in /Users/chrisrzhou/Github/cypress-coverage-repo/coverage/coverage-final.json +0ms
code-coverage There are 0 key(s) in /Users/chrisrzhou/Github/cypress-coverage-repo/coverage/coverage-final.json +0ms
Versions
- What is this plugin's version? @cypress/[email protected] (latest)
- What is Cypress version? [email protected], @cypress/[email protected], @cypress/[email protected] (see
package.jsonin repo for more details). - What is your operating system? Mac
- What is the shell? zsh
- What is the Node version? v12.22.1
- What is the NPM version? 6.14.12
- How do you instrument your application? Through the official docs' recommendation. See repo below for details.
- When running tests, if you open the web application in regular browser, and open DevTools, do you see
window.__coverage__object? Following the official docs, I can seewindow.__coverage__object for the files that the test is touching.

- Is there
.nyc_outputfolder? Is there.nyc_output/out.jsonfile. Is it empty? Both folder and file exists, the contents is just the empty object{}. - Do you have any custom NYC settings in
package.json(nycobject) or in other NYC config files No - Do you run Cypress tests in a Docker container? No, just locally
Describe the bug
Bug Report
Repro Link
https://github.com/chrisrzhou/cypress-code-coverage-issue-472
Context
It is a minimal example with the following requirements:
- Is an ESM module
- i.e.
"type": "module"is explicitly marked in thepackage.json - appropriate Cypress files need to be marked as
.cjsin order for the tests to run.
Incypress/plugins/index.cjsand fields incypress.json.
- i.e.
- Uses component testing (i.e.
@cypress/reactand usingopen-ctandrun-cttest runners). - Uses code coverage (i.e.
@cypress/code-coverageandbabel-plugin-istanbulbased on the official docs for instrumentation).
The requirements above are needed in the actual bug faced in the project, so the repo is capturing the minimal configuration of reproducing the same bug.
Reproduce
npm i
npm test
The test runner runs fine, and tests the code correctly.
Expected Behavior
Code coverage to output something meaningful in .nyc_output/out.json
Actual Behavior
.nyc_output/out.json is an empty object. The test runner complains that the code is not instrumented.
- 主要言語
- TypeScript
- スター
- 440
- フォーク
- 114
- 平均マージ
- 42分
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cypress-io/code-coverage のほかの issue
-
難易度 3/5 半日 初心者へのやさしさ 40/100
cypress-io/code-coverage#1018 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
cypress-io/code-coverage#993 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
cypress-io/code-coverage#967 ·
メンテナーはふだん 1 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
cypress-io/code-coverage#959 ·
メンテナーはふだん 1 日以内に返信
-
performance
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
cypress-io/code-coverage#933 ·
メンテナーはふだん 1 日以内に返信
cypress-io/code-coverage の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Open-Earth-Foundation/CityCatalyst#3399 ·
メンテナーはふだん 2 日以内に返信
-
userReport
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
nkprasad12/morcus-net#631 ·
メンテナーはふだん 1 日以内に返信
-
fix(app): fail closed if GetGeneralSetting fails during initialization対応中かも @kalavt が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
nekko-labs/nekko-agent#1756 ·
メンテナーはふだん 1 日以内に返信
-
needs-area-label
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
メンテナーはふだん 2 日以内に返信