Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 2.5 KB

sonarcloud.md

File metadata and controls

45 lines (33 loc) · 2.5 KB

SonarCloud Workflow

SonarCloud is used to gather quality metrics, including static code analysis for Javascript.

In order to report unit test code coverage back to SonarCloud, we need to use the Chrome Debugger Protocol to extract coverage data, and transform it to SonarCloud's expected Generic Report Format.

Steps

  • checkout the repository
  • generate a certificate
  • run a nginx server with the certificate on https://localhost/todos
  • install chromium-browser, jq, curl and websocat
  • run chromium-browser in headless mode and instruct over the Chrome Debugger Protocol web socket to collect coverage after navigating to the unit test documents.
  • transform Chrome coverage format to SonarCloud Generic Coverage Report format with transform-coverage.js
  • run SonarCloud Scan with coverage report path configured

Requirements

Example

sonarcloud-bot

sonarcloud

Chrome code coverage

See A quick look at how Chrome's JavaScript code coverage feature works

Chrome Debugger Protocol messages used:

{"id":1,"method":"Profiler.enable"}
{"id":3,"method":"Profiler.startPreciseCoverage","params":{"callCount":true,"detailed":true,"allowTriggeredUpdates":false}}
{"id":4,"method":"Page.navigate","params":{"url":"https://localhost/todos/classes/offline-cache.html"}}

{"id":5,"method":"Profiler.takePreciseCoverage"}