This project was generated with Angular CLI version 7.3.5 and modified to be a useful example of scanning such a project with SonarQube.
Code coverage is assessed using the Istanbul reporter for Karma, configured in the karma.conf.js file. In the build.sh
script, you'll see we run the ng test
command with the --code-coverage
parameter to make sure coverage results are captured. All that is needed in addition is to inform the sonar-scanner of the location of the LCOV results file (see the file sonar-project.properties
).
Make sure you have node.js 8.9 or higher along with npm 5.5.1 or higher available on your PATH. Additionally, the test configuration for this project expects Google Chrome to be installed.
Run build.sh
, which will first use the Angular CLI to run unit tests against the project and then invoke the sonar scanner.
If you're curious to see what this sample app does, run ng serve
for a dev server. Navigate to http://localhost:4200/
. The app will automatically reload if you change any of the source files. If the ng
command is not found, it's probably because you don't have the Angular CLI installed globally. In this case, first run npm install
and then run ./node_modules/.bin/ng serve
.