Skip to content

Configurable vitest coverage reportsDirectory (currently not configurable) #31975

@StefanMuellerCH

Description

@StefanMuellerCH

Command

test

Description

We are using Angular 21. Currently, there are several options in angular.json to configure vitest-outputs but there is no option to configure the test.coverage.reportsDirectory in angular.json.

Configuring the test.coverage.reportsDirectory in a vitest.config.ts file like below does not work either, as angular overwrites the coverage-reports-directory path when calling vitest. The explicitly configured vitest-config option is ignore.

import {defineConfig} from 'vitest/config'
export default defineConfig({
  test: {
    coverage: {
      provider: 'v8',
      reporter: ['lcov'],
      reportsDirectory: '.target/coverage' // This option is ignored as Angular passes the path when calling vitest!
    }
  }
})

Describe the solution you'd like

There are 2 possible solutions that would fit:

A) Provide an option in angular.json to specifiy the coverageReportsDirectory - This would be in-line with the already existing options like reporters, coverageReporters and more.

B) Angular should not pass the test.coverage.reportsDirectory to vitest if apps configured an explicit vitest.config.ts file with explicit configured reportsDirectory. Explicit configs should win over implicit configs.

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions