How do I read an Istanbul Coverage Report?

前端 未结 3 1191
野性不改
野性不改 2021-01-29 17:19

I\'ve always used Jasmine for my unit tests, but recently I started using Istanbul to give me code coverage reports. I mean I get the gist of what they are trying to te

3条回答
  •  醉话见心
    2021-01-29 17:55

    Running istanbul should also produce an HTML file for the report (should be in the coverage folder). This HTML should give you drill-down information when you click on files/folders.

    The percentage of functions covered is calculated by the number of functions that were called during tests, divided by total number of functions. Same goes for lines and statements (which will usually be close to each other unless you have very long statements). Branches mean decision points like if-else blocks. For example, say your code only contains one if-else statement, and your tests only pass through the if part but not the else part, then your branches percentage should be 50%.

    Hope that makes things clearer.

提交回复
热议问题