unit-test-quality: "dependencies found but no mocking" flags every test that imports the module under test

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

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

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

評価

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

調査の方向性

Start with test-coverage-analyzer-configuration.ts:101-106 and test-coverage-analyzer-validation-patterns.ts:105-116, then inspect the unit test quality rules and Jest configuration. Reproduce the listed false positives and check how the rules handle external boundaries, mock cleanup flags, parameterized tests, edge-case indicators, and setTimeout. Done means the reported false positives are addressed while the listed real debt remains detectable.

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

説明

bug

Found in the 8.0.0 self-audit triage: RoC 7.29.1 (npm, 5fc54afe) on a clean clone of develop at 2d2fa9a, with typescript resolvable (verdict compliance, 0 failed / 46 warnings). The bucket method and per-law tables are kept by QA; counts are from that run.

What happens

486 of 661 Unit Test Quality findings are "Dependencies found but no mocking detected". Any import … from is a "dependency" (test-coverage-analyzer-configuration.ts:101-106, IMPORT_STATEMENT: /import\s+.*from/), and the rule fires when no mock/spy/stub word appears (test-coverage-analyzer-validation-patterns.ts:105-116). 363 of the 486 files import only relative project modules (the module under test), 99 more add only Node built-ins; tests that spawn the built CLI or build temp-dir fixtures are told to mock.

Other templates of the same law:

  • "No edge case testing" (74): the word list misses negative titles ("does NOT flag …") and toBe(false); constant tables with no input are asked for edge cases.
  • "Mock functions without cleanup" (4): jest.config.js sets resetMocks/restoreMocks/clearMocks: true; the detector never reads it.
  • "Excessive mocking": tests are counted with /it\s*\(/ only, so it.each counts 0 tests.
  • "setTimeout usage": matches jest.setTimeout(N).

Real debt that should stay visible: 9 identical 50 ms sleeps in afterAll, a wall-clock-dependent performance test, ~18 tests spying pure helpers (45 mock setups for 16 tests).

Suggested direction

Count only external boundaries the test actually calls (network/db clients, child_process, the clock), never a relative import; no mock demand for spawn-the-CLI or temp-fixture tests (or drop "no mocks" as a defect); read the jest config's mock reset flags; count it.each(/test(; accept negative titles and toBe(false) as edge cases.

主要言語
TypeScript
スター
0
フォーク
0
平均マージ
38分
マージ済み PR(30日)
96

環境構築

はじめの一歩

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

Rule-Of-Code/RoC のほかの issue

Rule-Of-Code/RoC の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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