0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Jestのカバレッジの意味を理解する

0
Posted at

はじめに

Jestでカバレッジを取得すると、以下のような結果が生成されます。

-----------|----------|----------|----------|----------|-------------------|
File       |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-----------|----------|----------|----------|----------|-------------------|
All files  |    75.62 |     61.8 |      100 |    66.51 |                   |
target.ts  |    75.62 |     61.8 |      100 |    66.51 |         32,95-100 |
-----------|----------|----------|----------|----------|-------------------|

それぞれの意味は以下の通りです。

  • Stmts(Statements):if文や代入、関数呼び出しなどの「実行可能な文」がどれだけ実行されたかを表します
  • Branch(Branches):if / elseswitch などの分岐がどれだけ網羅されたか
  • Funcs(Functions):定義された関数のうち、実際に呼び出された割合
  • Lines(Lines):実行可能な行のうち、実際に実行された行の割合

なぜ定義が曖昧なのか?

それぞれの意味について定義した公式のドキュメントはないようです。

Jestはカバレッジ取得にあたって、Istanbul(istanbuljs)というライブラリを使っています。そのため、JestのドキュメントでもIstanbulの情報を参照するように案内されています。

一方で、Istanbulのドキュメントを見ると、これらの指標は一般的なカバレッジ用語であるため、詳細な定義が省略されています。そのため、コミュニティでよく参照されている以下の資料が実質的なリファレンスになっています。

環境

  • Jest: 26.6.3
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?