fix(coverage): handle query param based transforms correctly#8418
fix(coverage): handle query param based transforms correctly#8418sheremet-va merged 3 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. |
| // we are using a normalized file name by default because this is what | ||
| // Vite expects in the source maps handler | ||
| filename: module.file || filename, | ||
| filename: module.id, |
There was a problem hiding this comment.
The module.file || filename did not contain query params. module.id does. We need to have the query present in vm.RunningCodeOptions.filename so that V8 reports those files properly. Otherwise we would see same file URL multiple times, and could not identify which coverage belongs to which file transform.
Before:
{
scriptId: '305',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts',
functions: [...]
}
{
scriptId: '306',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts',
functions: [...]
}
{
scriptId: '307',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts',
functions: [...]
}After:
{
scriptId: '305',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts',
functions: [...]
}
{
scriptId: '306',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts%3Fquery=first',
functions: [...]
}
{
scriptId: '307',
url: 'file:///Users/ari/Git/vitest/test/coverage-test/fixtures/src/query-param-transformed.ts%3Fquery=second',
functions: [...]
}Note that the offset of functions there maps to different positions, based on query params.
14e2423 to
9d43490
Compare
@vitest/browser
@vitest/coverage-istanbul
@vitest/coverage-v8
@vitest/expect
@vitest/mocker
@vitest/pretty-format
@vitest/runner
@vitest/snapshot
@vitest/spy
@vitest/ui
@vitest/utils
vite-node
vitest
@vitest/web-worker
@vitest/ws-client
commit: |
|
Marking #6029 as linked too, as the minimal reproduction seems to work properly with this fix. I guess the auto-import does something with query params. |
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:.