I'm using Node 14.x
and Jest 26.x
. There is a npm test
script in package.json file which contains the following:
cross-env NODE_ENV=test jest --coverage --forceExit
When I run it locally, it generates the code coverage report in ./coverage
directory. The contents of ./coverage
directory is as follows:
lcov-report (folder)
clover.xml
coverage-final.json
lcov.info
It looks like clover.xml
contains code coverage report. There are more details which can be found in lcov-report
folder.
I've setup the Azure DevOps pipeline as follows for code coverage:
...
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: '**/junit.xml'
# Publish code coverage results
# Publish Cobertura or JaCoCo code coverage results from a build
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: '$(System.DefaultWorkingDirectory)/coverage/clover.xml'
After running the pipeline, Azure DevOps doesn't seem to find the cover.xml
file. I get the following error:
##[debug]Result: true
##[debug]Report directory: /home/vsts/work/_temp/cchtml
Reading code coverage summary from '/home/vsts/work/1/s/coverage/clover.xml'
##[warning]No coverage data found. Check the build errors/warnings for more details.
##[debug]Processed: ##vso[codecoverage.publish codecoveragetool=Cobertura;summaryfile=/home/vsts/work/1/s/coverage/clover.xml;reportdirectory=/home/vsts/work/_temp/cchtml;]
I also tried the following options for summaryFileLocation
but all resulted in same error.
'**/coverage/clover.xml'
'$(System.DefaultWorkingDirectory)/**/coverage/clover.xml'
I understand that the format of clover.xml
may not be the same as Cobertura
or JaCoCo
, but at least Azure should be able to locate the file.
What I'm missing?