Check! Code Coverage with Jest on Azure DevOps

Kazumi IWANAGA (OHIRA)
1 min readDec 15, 2019

You can publish code coverage results of Node.js or JavaScript project with Jest on Azure DevOps.

Test results by Jest on Azure DevOps
Code Coverage by 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! 🙌

References

--

--

Kazumi IWANAGA (OHIRA)

Hello! :) I’m a developer, Microsoft MVP(Azure). My interests: Azure, Serverless, IaC, Container, IoT, and other many exciting things!