Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support configuring coverage reporter options #2658

Closed
4 tasks done
AriPerkkio opened this issue Jan 13, 2023 · 0 comments · Fixed by #2690
Closed
4 tasks done

Support configuring coverage reporter options #2658

AriPerkkio opened this issue Jan 13, 2023 · 0 comments · Fixed by #2690
Assignees
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature

Comments

@AriPerkkio
Copy link
Member

Clear and concise description of the problem

Add support for configuring various options of different Istanbul reporters. This applies to both @vitest/coverage-c8 and @vitest/coverage-istanbul.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/276d95e4304b3670eaf6e8e5a7ea9e265a14e338/types/istanbul-reports/index.d.ts

Reporters have various options that solve different issues, e.g. using relative paths in monorepo setups: #1902 (comment).

Suggested solution

Similar API as Jest has https://jestjs.io/docs/configuration#coveragereporters-arraystring--string-options.

Vitest's documentation could look like this:

reporter

  • Type: string | string[] | [string, {}][]
  • Default: ['text', 'html', 'clover', 'json']
  • Available for providers: 'c8' | 'istanbul'
  • CLI: --coverage.reporter=<reporter>, --coverage.reporter=<reporter1> --coverage.reporter=<reporter2>

Coverage reporters to use. See istanbul documentation for detailed list of all reporters. See @types/istanbul-reporter for details about reporter specific options.

The reporter has three different types:

  • A single reporter: { reporter: 'html' }
  • Multiple reporters without options: { reporter: ['html', 'json'] }
  • A single or multiple reporters with reporter options:
    {
      reporter: [
        ['lcov', { 'projectRoot': './src' }],
        ['json', { 'file': 'coverage.json' }],
        ['text']
      ]
    }

Alternative

No response

Additional context

  • Requires unreleased c8@7.13.0.
  • Requires refactoring Vitest's internal coverage typings first

Validations

@AriPerkkio AriPerkkio added enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature labels Jan 13, 2023
@AriPerkkio AriPerkkio self-assigned this Jan 13, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jun 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request feat: coverage Issues and PRs related to the coverage feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant