Skip to content

Commit de5af29

Browse files
authored
fix(coverage): v8 autoAttachSubprocess to use .tmp directory (#11632)
1 parent fb15015 commit de5af29

2 files changed

Lines changed: 26 additions & 4 deletions

File tree

‎packages/coverage-v8/src/index.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const mod: CoverageProviderModule & {
3131
enabled = true
3232

3333
if (autoAttachSubprocess) {
34-
this.extendedContextCoverageDir = resolve(reportsDirectory, 'tmp', randomUUID())
34+
this.extendedContextCoverageDir = resolve(reportsDirectory, '.tmp', randomUUID())
3535
process.env.NODE_V8_COVERAGE = this.extendedContextCoverageDir
3636
}
3737

‎test/coverage-test/test/temporary-files.test.ts‎

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readdirSync } from 'node:fs'
22
import { resolve } from 'node:path'
33
import { expect } from 'vitest'
4-
import { runVitest, test } from '../utils'
4+
import { isBrowser, isV8Provider, runVitest, test } from '../utils'
55

66
test('temporary files are removed after test', async () => {
77
await runVitest({
@@ -12,9 +12,31 @@ test('temporary files are removed after test', async () => {
1212
const coveragePath = resolve('./coverage')
1313
const files = readdirSync(coveragePath)
1414

15-
expect(files).not.toContain('.tmp')
15+
expect.soft(files).not.toContain('.tmp')
1616

17-
expect(files).toMatchInlineSnapshot(`
17+
expect.soft(files).toMatchInlineSnapshot(`
18+
[
19+
"coverage-final.json",
20+
]
21+
`)
22+
})
23+
24+
test('temporary files from autoAttachSubprocess are removed after test', async ({ skip }) => {
25+
skip(!isV8Provider() || isBrowser(), 'V8 + node only feature')
26+
27+
await runVitest({
28+
include: ['fixtures/test/child-process.test.ts'],
29+
pool: 'forks',
30+
coverage: { reporter: 'json', autoAttachSubprocess: true },
31+
})
32+
33+
const coveragePath = resolve('./coverage')
34+
const files = readdirSync(coveragePath)
35+
36+
expect.soft(files).not.toContain('.tmp')
37+
expect.soft(files).not.toContain('tmp')
38+
39+
expect.soft(files).toMatchInlineSnapshot(`
1840
[
1941
"coverage-final.json",
2042
]

0 commit comments

Comments
 (0)