File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { After, Before } from "@cucumber/cucumber";
9
9
import { World } from "./world" ;
10
10
import { ITestCaseHookParameter } from "@cucumber/cucumber/lib/support_code_library_builder/types" ;
11
11
import { MODES } from "@pollyjs/utils" ;
12
+ import { FetchError } from "node-fetch" ;
12
13
13
14
Polly . register ( NodeHttpAdapter ) ;
14
15
Polly . register ( FSPersister ) ;
@@ -70,9 +71,18 @@ Before(function (
70
71
) {
71
72
fs . mkdirSync ( path . dirname ( frozen ) , { recursive : true } ) ;
72
73
fs . writeFileSync ( frozen , JSON . stringify ( date ) ) ;
74
+ } else if ( this . polly ?. mode == MODES . REPLAY ) {
75
+ throw new Error ( `Time file '${ frozen } ' not found: create one setting \`RECORD=true\` or ignore it using \`RECORD=none\`` ) ;
73
76
}
74
77
}
75
78
79
+ const cassette = path . join ( recordingsDir , this . polly ?. recordingId , "recording.har" )
80
+ const cassetteExists = fs . existsSync ( cassette )
81
+
82
+ if ( ! cassetteExists && this . polly ?. mode == MODES . REPLAY ) {
83
+ throw new Error ( `Cassette '${ cassette } ' not found: create one setting \`RECORD=true\` or ignore it using \`RECORD=none\`` ) ;
84
+ }
85
+
76
86
const now = date . getTime ( ) / 1000 ;
77
87
const name = pickle . name ?. replace ( / [ ^ A - Z a - z 0 - 9 ] + / g, "_" ) . substr ( 0 , 100 ) ;
78
88
const prefix =
You can’t perform that action at this time.
0 commit comments