For those who will have the same problem here is the solution I found:
sonarCloud accepts type: xml code coverage file, with the tool cobertura.
Like code-coverage.xml output.
I had to use the frameworks from my first message, defined in my package.json
1. So I use the following tasks on my scan pipeline:
- script: |
npx ng test --code-coverage --progress --karma-config src/karma-ci.conf.js --prod
displayName: Generate unit tests and report coverage
This task can be replaced by this one below.
- task: Npm@1
customCommand: run test:ci
displayName: Launch unit tests
But you will need to define in your package.json the script that can call the Npm@1 command custom run test:ci. By adding this to the script:
"test:ci": "ng test --watch=false --karma-config src/karma-ci.conf.js",
2. And the other tasks of my pipline for publish unit tests and run analysis, and publish quality gate.
- task: PublishTestResults@2
displayName: Publish unit test results
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage report
- task: SonarCloudAnalyze@1
displayName: "Run Code Analysis"
- task: SonarCloudPublish@1
displayName: "Publish Quality Gate Result"
2. The final result
I still have a doubt about the result of code coverage that
my report shows on my last capture 0.0% <85.0%.
It is not consistent to get 0.0% if my code coverage of my 2nd capture shows the following percentage:
- 33% of line covered and
- 29% branch coverage
So I wonder if my report has been sent to sonarCloud, can you confirm it or explain it to me or am I wrong?
if you need my pipeline logs let me know.