Check! Code Coverage with Jest on Azure DevOps
You can publish code coverage results of Node.js or JavaScript project with Jest on Azure DevOps.
Azure DevOps has a task named PublishCodeCoverageResults
that can do that and supports these formats such as Cobertura and JaCoCo.
Jest has a coverage feature that includes istanbul that reports coverage as cobertura
format. (So you can do that without nyc).
The way is easy. Generate a coverage file with cobertura
format and let the PublishCodeCoverageResults
task read.
First, you prepare a script in package.json like below. The command is jest --coverage --coverageReporters=cobertura
.
Then, create a new pipeline file or edit yours like below. See the code that running npm run coverage
in script
task and run PublishCodeCoverageResults
task.
That’s all! 🙌