@@ -40,6 +40,7 @@ class FuzzTest {
40
40
jestTestFile ;
41
41
jestTestNamePattern ;
42
42
jestRunInFuzzingMode ;
43
+ coverage ;
43
44
44
45
constructor (
45
46
sync ,
@@ -53,6 +54,7 @@ class FuzzTest {
53
54
jestTestFile ,
54
55
jestTestName ,
55
56
jestRunInFuzzingMode ,
57
+ coverage ,
56
58
) {
57
59
this . sync = sync ;
58
60
this . runs = runs ;
@@ -65,6 +67,7 @@ class FuzzTest {
65
67
this . jestTestFile = jestTestFile ;
66
68
this . jestTestNamePattern = jestTestName ;
67
69
this . jestRunInFuzzingMode = jestRunInFuzzingMode ;
70
+ this . coverage = coverage ;
68
71
}
69
72
70
73
execute ( ) {
@@ -78,6 +81,7 @@ class FuzzTest {
78
81
for ( const bugDetector of this . disableBugDetectors ) {
79
82
options . push ( "--disable_bug_detectors=" + bugDetector ) ;
80
83
}
84
+ if ( this . coverage ) options . push ( "--coverage" ) ;
81
85
options . push ( "--" ) ;
82
86
options . push ( "-runs=" + this . runs ) ;
83
87
if ( this . forkMode ) options . push ( "-fork=" + this . forkMode ) ;
@@ -101,6 +105,7 @@ class FuzzTest {
101
105
const cmd = "npx" ;
102
106
const options = [
103
107
"jest" ,
108
+ this . coverage ? "--coverage" : "" ,
104
109
this . jestTestFile ,
105
110
'--testNamePattern="' + this . jestTestNamePattern + '"' ,
106
111
] ;
@@ -145,6 +150,7 @@ class FuzzTestBuilder {
145
150
_jestTestFile = "" ;
146
151
_jestTestName = "" ;
147
152
_jestRunInFuzzingMode = false ;
153
+ _coverage = false ;
148
154
149
155
/**
150
156
* @param {boolean } sync - whether to run the fuzz test in synchronous mode.
@@ -241,6 +247,11 @@ class FuzzTestBuilder {
241
247
return this ;
242
248
}
243
249
250
+ coverage ( coverage ) {
251
+ this . _coverage = coverage ;
252
+ return this ;
253
+ }
254
+
244
255
build ( ) {
245
256
if ( this . _jestTestFile === "" && this . _fuzzEntryPoint === "" ) {
246
257
throw new Error ( "fuzzEntryPoint or jestTestFile are not set." ) ;
@@ -262,6 +273,7 @@ class FuzzTestBuilder {
262
273
this . _jestTestFile ,
263
274
this . _jestTestName ,
264
275
this . _jestRunInFuzzingMode ,
276
+ this . _coverage ,
265
277
) ;
266
278
}
267
279
}
0 commit comments