Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vitest coverage on azure devops

I'm trying to run an azure devops pipeline that contains a vitest run with coverage. The issue is that the azure coverage collector plugin accepts only jacoco/cobertura formats. I've seen that for jest is it possible to run with a cobertura reporter. Is there anyway of doing this for vitest?

Thank you

like image 372
QuickQuestion Avatar asked Jul 16 '26 23:07

QuickQuestion


1 Answers

Vitest supports c8 and istanbul for coverage, they both support Cobertura format.

Wherever you define your test settings vite.config.ts or vitest.config.ts set the coverage reporter to generate the cobertura format.

import { defineConfig } from 'vitest/config'

export default defineConfig({
  test: {
    coverage: {
      reporter: ['cobertura', 'text'],
    },
  },
})

It will output by default at /coverage/cobertura-coverage.xml. You can then feed this into the PublishCodeCoverageResults task.

like image 121
Steven B. Avatar answered Jul 18 '26 22:07

Steven B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!