@@ -42,15 +42,19 @@ export class FuzzerStartError extends FuzzerError {}
42
42
// Use Jests global object definition.
43
43
const g = globalThis as unknown as Global . Global ;
44
44
45
- export type FuzzTest = ( name : Global . TestNameLike , fn : FuzzTarget ) => void ;
45
+ export type FuzzTest = (
46
+ name : Global . TestNameLike ,
47
+ fn : FuzzTarget ,
48
+ timeout ?: number
49
+ ) => void ;
46
50
47
51
export const skip : FuzzTest = ( name ) => {
48
52
g . test . skip ( toTestName ( name ) , ( ) => {
49
53
return ;
50
54
} ) ;
51
55
} ;
52
56
53
- export const fuzz : FuzzTest = ( name , fn ) => {
57
+ export const fuzz : FuzzTest = ( name , fn , timeout = 5000 ) => {
54
58
const testName = toTestName ( name ) ;
55
59
56
60
// Request the current test file path from the worker to create appropriate
@@ -64,15 +68,10 @@ export const fuzz: FuzzTest = (name, fn) => {
64
68
// points to the element containing the fuzz function.
65
69
const testStatePath = currentTestStatePath ( testName ) ;
66
70
67
- // The timeout setting is extracted from the test state and defaults to 5s.
68
- // Setting timeouts on this level is necessary, as they apply to the
69
- // individual inputs and not the whole run.
70
- const timeout = currentTimeout ( ) ;
71
-
72
71
const corpus = new Corpus ( testFile , testStatePath ) ;
73
72
74
73
const fuzzingConfig = loadConfig ( ) ;
75
- fuzzingConfig . timeout = timeout ;
74
+ if ( fuzzingConfig . timeout ) timeout = fuzzingConfig . timeout ;
76
75
77
76
if ( fuzzingConfig . dryRun ) {
78
77
runInRegressionMode ( name , fn , corpus , timeout ) ;
@@ -231,7 +230,3 @@ const currentTestStatePath = (testName: string): string[] => {
231
230
}
232
231
return elements ;
233
232
} ;
234
-
235
- const currentTimeout = ( ) : number => {
236
- return circus . getState ( ) . testTimeout || 5000 ;
237
- } ;
0 commit comments