fix(coverage): browser + v8 in source tests missing#7946
fix(coverage): browser + v8 in source tests missing#7946sheremet-va merged 2 commits intovitest-dev:mainfrom
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
528b7af to
21a2dad
Compare
| if (coverage.url.includes('?browserv=') || coverage.url.includes('&browserv=')) { | ||
| return false | ||
| } | ||
|
|
There was a problem hiding this comment.
Need to check with Storybook folks to see that this doesn't break coverage reports there. This was used to exclude *.stories.* from appearing in coverage report.
There was a problem hiding this comment.
*.stories.* are now visible on coverage report 😢
There was a problem hiding this comment.
Storybook can now exclude story files inside the configureVitest hook
There was a problem hiding this comment.
Yep, that works! Using this in fresh Storybook project fixes the issue:
{
name: "exclude-stories",
configureVitest(context) {
if (context.vitest.config.coverage.enabled) {
context.vitest.config.coverage.exclude.push("**/*.stories.**");
}
},Related tests in #8009
@vitest/browser
@vitest/coverage-istanbul
@vitest/expect
@vitest/coverage-v8
@vitest/mocker
@vitest/pretty-format
@vitest/runner
@vitest/spy
@vitest/snapshot
@vitest/ui
@vitest/utils
vite-node
vitest
@vitest/web-worker
@vitest/ws-client
commit: |
21a2dad to
c5e4c24
Compare
| const project = parentServer.vitest.getProjectByName(parentServer.config.name) | ||
| if (!project._isCachedTestFile(id) || !code.includes('import.meta.vitest')) { | ||
|
|
||
| if (!project._isCachedTestFile(filename) || !code.includes('import.meta.vitest')) { |
There was a problem hiding this comment.
This change is needed so that /Users/x/vitest/test/coverage-test/fixtures/src/in-source.ts?import&browserv=1747838764408 is recognized as cached test file.
Description
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.