5

I have CI setup for a GitLab repository and the job contains the following output to the STDOUT.

=============================== Coverage summary ===============================
Statements   : 94.25% ( 291/333 )
Branches     : 62.29% ( 53/75 )
Functions    : 73.32% ( 170/196 )
Lines        : 94.68% ( 533/569 )
================================================================================

In the .gitlab-ci.yml file for the job I have the coverage: /^Statements\s*:\s*([^%]+)/. As well, in the CI/CD settings for the repository I have ^Statements\s*:\s*([^%]+) set.

Yet code coverage appears to be Unknown on the code coverage badge.

0

2 Answers 2

3

You might need to set the multiline flag

coverage: /^Statements\s*:\s*([^%]+)/m
#                                   ^^^
1
1

Turns out that the build needs to be passing. So a Mocha exception for example of a failing test will prevent code coverage from being extracted.

2
  • can you please share your .yml file (or a part of it where you fixed it), I'm having the same issue
    – user10415043
    Commented Dec 6, 2018 at 22:58
  • @YashKaranke in my case the build needed to be passing in order for the coverage to be parsed and displayed. Commented Dec 7, 2018 at 0:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.