@@ -2,6 +2,7 @@ import * as vscode from 'vscode';
2
2
import { join } from 'path' ;
3
3
import { Runner , RunnerEvent , Options } from 'jest-editor-support' ;
4
4
import { JestExtContext , WatchMode } from '../JestExt/types' ;
5
+ import { collectCoverage } from '../JestExt/helper' ;
5
6
import { extensionId } from '../appGlobals' ;
6
7
import { Logging } from '../logging' ;
7
8
import { JestProcessInfo , JestProcessRequest , ProcessStatus , UserDataType } from './types' ;
@@ -34,6 +35,7 @@ export class JestProcess implements JestProcessInfo {
34
35
private desc : string ;
35
36
public readonly request : JestProcessRequest ;
36
37
public _status : ProcessStatus ;
38
+ private coverage : boolean | undefined ;
37
39
private autoStopTimer ?: NodeJS . Timeout ;
38
40
39
41
constructor (
@@ -44,9 +46,11 @@ export class JestProcess implements JestProcessInfo {
44
46
this . extContext = extContext ;
45
47
this . request = request ;
46
48
this . logging = extContext . loggingFactory . create ( `JestProcess ${ request . type } ` ) ;
47
- this . id = `${ request . type } -${ SEQ ++ } ` ;
48
- this . desc = `id: ${ this . id } , request: ${ requestString ( request ) } ` ;
49
49
this . _status = ProcessStatus . Pending ;
50
+ this . coverage = collectCoverage ( this . getRequestCoverage ( ) , this . extContext . settings ) ;
51
+ const extra = ( this . coverage ? 'with-coverage:' : '' ) + `${ SEQ ++ } ` ;
52
+ this . id = `${ request . type } :${ extra } ` ;
53
+ this . desc = `id: ${ this . id } , request: ${ requestString ( request ) } ` ;
50
54
}
51
55
52
56
public get status ( ) : ProcessStatus {
@@ -122,6 +126,15 @@ export class JestProcess implements JestProcessInfo {
122
126
return `"${ removeSurroundingQuote ( aString ) } "` ;
123
127
}
124
128
129
+ private getRequestCoverage ( ) : boolean | undefined {
130
+ if ( this . request . type === 'not-test' ) {
131
+ return ;
132
+ }
133
+ // Note, we are ignoring coverage = false use-case, which doesn't exist yet, by returning undefined
134
+ // and let the runMode to decide in createRunnerWorkspace()
135
+ return this . request . coverage || undefined ;
136
+ }
137
+
125
138
private getTestPathPattern ( pattern : string ) : string [ ] {
126
139
return this . extContext . settings . useJest30
127
140
? [ '--testPathPatterns' , pattern ]
@@ -210,6 +223,7 @@ export class JestProcess implements JestProcessInfo {
210
223
211
224
const runnerWorkspace = this . extContext . createRunnerWorkspace ( {
212
225
outputFileSuffix : this . request . schedule . queue === 'blocking-2' ? '2' : undefined ,
226
+ collectCoverage : this . coverage ,
213
227
} ) ;
214
228
215
229
const runner = new Runner ( runnerWorkspace , options ) ;
0 commit comments