Allow for declaring the nycrcPath to use custom-named configuration files.

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

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

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

評価

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

調査の方向性

まず、Cypress の設定が NYC の設定をどのように読み取るか、また plugin が現在どのようにデフォルトの .nycrc ファイルを検出しているかを追跡します。既存の設定テストと coverage テストを確認し、config.nycrcPath または config.env.nycrcPath で指定されたカスタムパスのサポートを検証します。Cypress が選択された設定を使用し、既存のデフォルト動作を維持できれば完了です。

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

説明

Is your feature request related to a problem? Please describe.
Right now, this plugin supports loading default named ".nycrcfiles, but cannot utilize a custom named one, like.nycrc.config.cypress.js`. An option to provide custom configuration options exist for other test frameworks, like vitest.

Specifically in the case I am using, I need to have distinct outputs between unit and component test coverage, where Vitest handles unit tests, and Cypress handles component tests. This is due to limitations of how Cypress handles source maps versus Vitest where line lengths do not align properly (and this is well-documented in this repo and in the official nyc repo as well). To avoid that issue, I need separate .nycrc configs for both test frameworks.

Cypress currently only supports default named .nycrc files, or a configuration defined in the package.json, but this limits how we can use nyc as it prefers the configuration used for Cypress over any other configurations that can exist. This is a problem if we need to merge results and report on total coverage combined by both, running nyc report will ignore the files matched in the unit test configuration.

Describe the solution you'd like
The plugin should allow for calling a custom nycrcPath when being declared in the Cypress configuration, either by config.nycrcPath or config.env.nycrcPath.

For an example, see here:
https://github.com/iFaxity/vite-plugin-istanbul?tab=readme-ov-file#istanbulplugin--opts--

Describe alternatives you've considered
I will need to use three .nycrc configurations which is incredibly messy:

  • .nycrc.config.mjs, a default config used only for accurate reporting of merged component + unit test code coverage results. This would be called in a command like npx nyc report --nycrc-path=./.nycrc.config.mjs. Specifying the path is necessary here.
  • .nycrc.config.component.mjs, a Cypress-specific configuration extended from the default; it must be loaded as part of the package.json using "nyc": { "extends": "./.nycrc.config.component.mjs" }. Running npx nyc report without declaring the path will utilize this config instead of the default, which is the main issue.
  • .nycrc.config.unit.mjs for Vitest files only.

Additional context
Add any other context or screenshots about the feature request here.

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