File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -98,7 +98,10 @@ export class IstanbulCoverageProvider extends BaseCoverageProvider implements Co
9898 relativePath : ! this . options . allowExternal ,
9999 } )
100100
101- this . coverageFilesDirectory = resolve ( this . options . reportsDirectory , '.tmp' )
101+ const shard = this . ctx . config . shard
102+ const tempDirectory = `.tmp${ shard ? `-${ shard . index } -${ shard . count } ` : '' } `
103+
104+ this . coverageFilesDirectory = resolve ( this . options . reportsDirectory , tempDirectory )
102105 }
103106
104107 resolveOptions ( ) {
Original file line number Diff line number Diff line change @@ -101,7 +101,10 @@ export class V8CoverageProvider extends BaseCoverageProvider implements Coverage
101101 relativePath : ! this . options . allowExternal ,
102102 } )
103103
104- this . coverageFilesDirectory = resolve ( this . options . reportsDirectory , '.tmp' )
104+ const shard = this . ctx . config . shard
105+ const tempDirectory = `.tmp${ shard ? `-${ shard . index } -${ shard . count } ` : '' } `
106+
107+ this . coverageFilesDirectory = resolve ( this . options . reportsDirectory , tempDirectory )
105108 }
106109
107110 resolveOptions ( ) {
Original file line number Diff line number Diff line change 1+ import { readdirSync } from 'node:fs'
2+ import { expect , test } from 'vitest'
3+
4+ test ( 'temporary directory is postfixed with --shard value' , ( ) => {
5+ const files = readdirSync ( './coverage' )
6+
7+ expect ( files ) . toContain ( '.tmp-1-4' )
8+ expect ( files ) . not . toContain ( '.tmp' )
9+ } )
Original file line number Diff line number Diff line change @@ -43,6 +43,14 @@ const testCases = [
4343 } ,
4444 assertionConfig : null ,
4545 } ,
46+ {
47+ testConfig : {
48+ name : 'temp directory with shard' ,
49+ include : [ 'option-tests/shard.test.ts' ] ,
50+ shard : '1/4' ,
51+ } ,
52+ assertionConfig : null ,
53+ } ,
4654]
4755
4856for ( const provider of [ 'v8' , 'istanbul' ] ) {
You can’t perform that action at this time.
0 commit comments