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

true coverage at launch --change #6020

Closed
4 tasks done
bad4iz opened this issue Jul 2, 2024 · 6 comments
Closed
4 tasks done

true coverage at launch --change #6020

bad4iz opened this issue Jul 2, 2024 · 6 comments
Labels
feat: coverage Issues and PRs related to the coverage feature

Comments

@bad4iz
Copy link
Contributor

bad4iz commented Jul 2, 2024

Clear and concise description of the problem

when I launch vitest coverage --change=develop . I want there to be a true coverage of those files that are shown in the coverage. Now the dependency files that have not been changed do not correctly show the coverage. It is worth 0 in functions. If you run the full coverage, then there is not 0.

image

image

Suggested solution

I can't say exactly how to do it, but it may be worth running tests for those files that are included in the coverage statistics so that the coverage is true.

Alternative

No response

Additional context

No response

Validations

@AriPerkkio
Copy link
Member

AriPerkkio commented Jul 2, 2024

To fix this we'll need to make major changes to --changed. #5237 (comment)

That would change what files are run with --changed flag, depending whether --coverage flag was also run. I don't think any other test runner has implemented this. Jest works similar as Vitest does now.

Also noted at #5314 (comment):

I think I'll leave this part out of this PR now: #5237 (comment). That requires some discussion as it changes functionality of --changed quite much.

@AriPerkkio AriPerkkio added p2-to-be-discussed Enhancement under consideration (priority) feat: coverage Issues and PRs related to the coverage feature and removed enhancement: pending triage labels Jul 2, 2024
@AriPerkkio
Copy link
Member

The team decided that this is not something that we will be implementing. By implementing this users would very likely run into cases where most tests of the code base end up running due to file dependencies. For example if your new test is testing file that imports a common utility package, this change would make Vitest run all the test files that depend on that utility package in any way. It eventually ends up matching test run without --changed flag.

This is also something that Jest does not implement so alignment is OK.

@AriPerkkio AriPerkkio removed the p2-to-be-discussed Enhancement under consideration (priority) label Jul 4, 2024
@bad4iz
Copy link
Contributor Author

bad4iz commented Jul 11, 2024

@AriPerkkio can then show coverage only for changed files? only for those for which tests are run?

@AriPerkkio
Copy link
Member

Using --changed will run only the files that are related to the changed files. Using --coverage with --changed will show coverage that those files covered. In #5237 we added support for coverage.all to limit it's scope only to the related files.

If the test files that --changed flag picks are covering unchanged files, those will show up in the report as well. You can use --coverage.include and/or --coverage.exclude to limit those.

@bad4iz
Copy link
Contributor Author

bad4iz commented Jul 18, 2024

@AriPerkkio how do I automatically generate a list --coverage.include=file_name from the modified files of the feature and develop branch ?
so that I can add this or these commands to ci/cd and package.json

@AriPerkkio
Copy link
Member

That sounds like something git could provide for you.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 2, 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
Projects
Archived in project
Development

No branches or pull requests

2 participants