Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • kresus kresus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 144
    • Issues 144
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 3
    • Merge requests 3
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • kresusapp
  • kresuskresus
  • Merge requests
  • !529

Use istanbul for code coverage

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Phyks requested to merge phyks/kresus:istanbul into master Oct 20, 2017
  • Overview 6
  • Commits 1
  • Pipelines 1
  • Changes 4

I just came across Istanbul which seems to integrate seemlessly with mocha to produce code coverage statistics.

It outputs stuff like

------------------------------|----------|----------|----------|----------|----------------|
File                          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------------|----------|----------|----------|----------|----------------|
All files                     |    45.33 |    28.67 |    17.92 |    44.24 |                |
 client/components/duplicates |    49.71 |    14.81 |    25.93 |    45.64 |                |
  default-params-modal.js     |       32 |        0 |        0 |       32 |... 113,117,119 |
  index.js                    |    60.98 |    23.53 |    38.89 |     54.9 |... 124,127,130 |
  item.js                     |    14.81 |        0 |        0 |    18.18 |... 44,45,46,54 |
 client/store                 |    25.14 |    12.24 |     7.46 |    24.07 |                |
  categories.js               |    16.88 |        0 |        0 |    16.22 |... 207,208,209 |
  helpers.js                  |    53.33 |       75 |       40 |    59.09 |... 29,30,36,42 |
  operation-types.js          |       40 |      100 |        0 |    44.44 | 10,11,12,14,18 |
  ui.js                       |    18.97 |        0 |     4.17 |    17.54 |... 210,214,218 |
 server                       |       30 |    10.53 |    28.57 |    30.43 |                |
  index.js                    |       30 |    10.53 |    28.57 |    30.43 |... 100,104,111 |
 server/lib                   |     83.7 |    80.56 |      100 |    87.21 |                |
  diff-accounts.js            |      100 |      100 |      100 |      100 |                |
  logger.js                   |    54.55 |    41.67 |      100 |    60.71 |... 67,68,72,73 |
------------------------------|----------|----------|----------|----------|----------------|

after running the tests, see for instance in the output of the CI.

This is just really basic use of istanbul to decide whether it is worth it or not. In particular, it does not compute 0 coverage for files which are not used at the moment.

Gitlab can then use a regex to parse code coverage from the CI logs and output it. Not sure how useful it can be, but might be a new interesting metrics to have, to have more incentive to write tests.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: istanbul