@cypress/code-coverage attempts to collect back-end coverage when we are not running end-to-end tests

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

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
cypress, typescript
領域
testing-qa

調査の方向性

このissueは168-172行目の support.js を指摘し、PR #474 を提案しています。まず、そのロジックと既存の expectBackendCoverageOnly 設定を確認してください。expectFrontendCoverageOnly が有効な場合の integration specs の動作を確認しつつ、現在のエンドツーエンド動作は維持してください。この場合にプラグインが存在しない /coverage URL へのアクセスを試みなければ完了です。

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

説明

Logs and screenshots

code-coverage combined NYC options { 'report-dir': './coverage', reporter: [ 'lcov', 'json-summary', 'text', 'cobertura' ], extension: [ '.jsx', '.js' ], excludeAfterRemap: false, sourceMap: false, instrument: false } +0ms
code-coverage reset code coverage in interactive mode +0ms
code-coverage reset code coverage in interactive mode +2s
code-coverage parsed sent coverage +8s
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +30ms
code-coverage parsed sent coverage +721ms
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/
code-coverage parsed sent coverage +2s
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +61ms
code-coverage parsed sent coverage +915ms
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +54ms
code-coverage parsed sent coverage +799ms
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +57ms
code-coverage parsed sent coverage +3s
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +50ms
code-coverage parsed sent coverage +2s
code-coverage wrote coverage file /Users/nyee2/dev/plugins/campaign-manager-web-plugin/.nyc_output/out.json +53ms

Versions

  • @cypress/code-coverage v3.9.7
  • Cypress 7.0.1
  • OS: MacOS Big Sur 11.4
  • shell: bash
  • Node v14.16.0
  • NPM 6.14.11
  • How do you instrument your application? babel-plugin-istanbul
  • do you see window.__coverage__ object? yes, window.__coverage__ exists and instrumentation works
  • Is there .nyc_output folder? yes coverage data is generated
  • custom NYC settings in package.json
  "nyc": {
    "extension": [
      ".jsx",
      ".js"
    ],
    "reporter": [
      "lcov",
      "json-summary",
      "text",
      "cobertura"
    ],
    "sourceMap": false,
    "instrument": false
  },
  • Do you run Cypress tests in a Docker container? yes in CI, MacOS locally

Describe the bug
The logic to determine if cypress is running an "end-to-end" test incorrectly resolves as true in my cypress tests, as our baseUrl and proxyUrl are different.

Code reference in question:
https://github.com/cypress-io/code-coverage/blob/c51751f9f9875c88aaacf648c738bec63b4163f1/support.js#L168-L172

From the above code, runningEndToEndTests evaluates to true if your baseUrl and proxyUrl are different, which they are in my case but I am not running end-to-end tests.

Cursor_and_campaign-manager-web-plugin

As my specType is integration, after tests complete an attempt is made to reach a /coverage URL which does not exist, thus failing the test.
Cursor_and_campaign-manager-web-plugin

I would like to propose perhaps setting & checking against a new config codeCoverage.expectFrontendCoverageOnly explicitly to determine if backend coverage needs to be collected (similar to the pre-existing expectBackendCoverageOnly config), eg. the above code reference could be augmented to preserve the existing behavior but allowing an explicit check against expectFrontendCoverageOnly

const runningEndToEndTests = baseUrl !== Cypress.config('proxyUrl')
const specType = Cypress._.get(Cypress.spec, 'specType', 'integration')
const isIntegrationSpec = specType === 'integration'
const expectFrontendCoverageOnly = Cypress._.get(Cypress.env('codeCoverage'), 'expectFrontendCoverageOnly', 
  false)

if (!expectFrontendCoverageOnly && runningEndToEndTests && isIntegrationSpec) {

Link to the repo
The code I am using @cypress/code-coverage is behind a private GH instance so I unfortunately can't share here. I have created https://github.com/cypress-io/code-coverage/pull/474 with the above suggestion

主要言語
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 を短くまとめたダイジェスト。