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 coverage of Astro files #6544

Closed
4 tasks done
lloydjatkinson opened this issue Sep 22, 2024 · 3 comments · Fixed by #6565
Closed
4 tasks done

Support coverage of Astro files #6544

lloydjatkinson opened this issue Sep 22, 2024 · 3 comments · Fixed by #6565
Labels
feat: coverage Issues and PRs related to the coverage feature p2-nice-to-have Not breaking anything but nice to have (priority)

Comments

@lloydjatkinson
Copy link

Clear and concise description of the problem

Provide coverage support for Astro files. Astro files comprise a "frontmatter" section, which is simply TS, and a template section which is TSX.

https://docs.astro.build/en/guides/testing/

Suggested solution

Provide seemless support for Astro files

Alternative

No response

Additional context

No response

Validations

@AriPerkkio
Copy link
Member

Code coverage should support Astro already.

@hi-ogawa
Copy link
Contributor

Should we maybe add .astro to default extension config? https://vitest.dev/config/#coverage-extension

@AriPerkkio
Copy link
Member

AriPerkkio commented Sep 25, 2024

Yep, let's add that. You can already use this in existing Astro project with following:

/// <reference types="vitest" />
import { getViteConfig } from "astro/config";
import { coverageConfigDefaults } from "vitest/config";

export default getViteConfig({
  test: {
    coverage: {
      enabled: true,
      extension: [...coverageConfigDefaults.extension, ".astro"],
    },
  },
});

Tested this quickly with an Astro project. It looks like their source maps have some gaps so coverage cannot be reported perfectly:

@AriPerkkio AriPerkkio added feat: coverage Issues and PRs related to the coverage feature p2-nice-to-have Not breaking anything but nice to have (priority) and removed enhancement: pending triage labels Sep 25, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: coverage Issues and PRs related to the coverage feature p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants