Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/coverage-v8/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,13 @@ function filterResult(coverage: ScriptCoverage['result'][number]): boolean {
return false
}

if (coverage.url === window.location.href) {
return false
}

if (coverage.url.includes('?browserv=') || coverage.url.includes('&browserv=')) {
return false
}

return true
}
2 changes: 1 addition & 1 deletion test/coverage-test/test/bundled-sources.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('bundled code with source maps to originals', async () => {
expect(files.find(file => file.includes('bundle.ts'))).toBeFalsy()
expect(files.find(file => file.includes('bundle.d.ts'))).toBeFalsy()

expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/bundled-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
await expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/bundled-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
})

coverageTest('run bundled sources', () => {
Expand Down
10 changes: 3 additions & 7 deletions test/coverage-test/test/include-exclude.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { expect } from 'vitest'
import { coverageConfigDefaults } from 'vitest/config'
import { coverageTest, normalizeURL, readCoverageMap, runVitest, test } from '../utils'
import { readCoverageMap, runVitest, test } from '../utils'

test('default exclude should ignore test files', async () => {
await runVitest({
include: [normalizeURL(import.meta.url)],
include: ['fixtures/test/math.test.ts'],
coverage: {
all: true,
reporter: 'json',
Expand All @@ -18,7 +18,7 @@ test('default exclude should ignore test files', async () => {

test('overriden exclude should not apply defaults', async () => {
await runVitest({
include: [normalizeURL(import.meta.url)],
include: ['fixtures/test/math.test.ts'],
coverage: {
all: true,
reporter: 'json',
Expand Down Expand Up @@ -63,7 +63,3 @@ test('test files are not automatically excluded from report when excludes is set
const files = coverageMap.files()
expect(files).toContain('<process-cwd>/fixtures/src/test-that-looks-like-source-file.ts')
})

coverageTest('dummy', () => {
expect(1 + 1).toBe(2)
})
2 changes: 1 addition & 1 deletion test/coverage-test/test/pre-transpiled-source.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ test('pre-transpiled code with source maps to original (#5341)', async () => {
expect(files.find(file => file.includes('transpiled.ts'))).toBeFalsy()
expect(files.find(file => file.includes('transpiled.d.ts'))).toBeFalsy()

expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/pre-transpiled-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
await expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/pre-transpiled-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
})
2 changes: 1 addition & 1 deletion test/coverage-test/test/results-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ test('coverage results matches snapshot', async () => {

const coverageJson = await readCoverageJson()

expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/results-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
await expect(JSON.stringify(coverageJson, null, 2)).toMatchFileSnapshot(`__snapshots__/results-${isV8Provider() ? 'v8' : 'istanbul'}.snapshot.json`)
})
2 changes: 2 additions & 0 deletions test/coverage-test/vitest.workspace.custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default defineWorkspace([
BROWSER_TESTS,

// Other non-provider-specific tests that should be run on browser mode as well
'**/include-exclude.test.ts',
'**/allow-external.test.ts',
'**/ignore-hints.test.ts',
'**/import-attributes.test.ts',
Expand All @@ -89,6 +90,7 @@ export default defineWorkspace([
BROWSER_TESTS,

// Other non-provider-specific tests that should be run on browser mode as well
'**/include-exclude.test.ts',
'**/allow-external.test.ts',
'**/ignore-hints.test.ts',
'**/import-attributes.test.ts',
Expand Down