Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When you run jest --coverage, what does the Branches column do/mean?

I ran my tests and this is what I received:

---------------|----------|----------|----------|----------|-------------------| File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s | ---------------|----------|----------|----------|----------|-------------------| All files | 100 | 0 | 100 | 100 | | Search | 100 | 100 | 100 | 100 | | index.js | 100 | 100 | 100 | 100 | | SearchResults | 100 | 0 | 100 | 100 | | index.js | 100 | 0 | 100 | 100 | 4 | ---------------|----------|----------|----------|----------|-------------------| Test Suites: 2 passed, 2 total Tests: 5 passed, 5 total Snapshots: 1 passed, 1 total Time: 4.678s I've changed something and now I have 0% on Branch column but I don't know what it means in order to improve it.

like image 793
jingteng Avatar asked Apr 15 '18 15:04

jingteng


People also ask

What are branches in jest coverage?

Branch coverage is a requirement that, for each branch in the program (e.g., if statements, loops), each branch have been executed at least once during testing. (It is sometimes also described as saying that each branch condition must have been true at least once and false at least once during testing.)

What does coverage mean in jest?

jest. · 4 comments. Your app's code coverage is what percentage of the code is currently covered by unit tests.

What does jest coverage report mean?

Jest: Coverage Report. Popular JavaScript frameworks can use Facebook's Jest to perform unit tests. Jest has the Coverage Report feature that allows us to check if our code covers all lines of the files we choose by generating an HTML file that we can open.

How does jest measure coverage?

Jest is collecting coverage only on the function under tests, not from the entire project. This means that despite we are seeing 100% coverage here, potentially we are testing only a fraction of our code. Now Jest is identify correctly what needs to be tested.


1 Answers

Conditional statements create branches of code which may not be executed (e.g. if/else). This metric tells you how many of your branches have been executed.

like image 169
Red Mercury Avatar answered Sep 23 '22 10:09

Red Mercury