@@ -186,7 +186,7 @@ describe('Testing RequestRecorder', { useTmpDir: true, timestamp: 0 }, () => {
186
186
expect ( recorder . get ( ) ) . to . deep . equal ( [ ] ) ;
187
187
} ) ;
188
188
189
- it ( 'Testing unknown modifiers (top level)' , async ( { recorder } ) => {
189
+ it ( 'Testing unknown modifiers (top level)' , async ( { capture } ) => {
190
190
prepareCassette ( {
191
191
'response|jsonStringify|toBase64' : { } ,
192
192
'body|jsonStringify|toBase64' : {
@@ -195,18 +195,19 @@ describe('Testing RequestRecorder', { useTmpDir: true, timestamp: 0 }, () => {
195
195
}
196
196
}
197
197
} ) ;
198
- await validate ( {
198
+ const err = await capture ( ( ) => validate ( {
199
199
json : true ,
200
- body : undefined ,
201
- response : ''
202
- } ) ;
203
- expect ( recorder . get ( ) ) . to . deep . equal ( [
204
- 'Unknown Modifier(s) detected: jsonStringify, toBase64' ,
205
- 'Unknown Modifier(s) detected: jsonStringify, toBase64'
206
- ] ) ;
200
+ body : {
201
+ payload : {
202
+ key : 'value'
203
+ }
204
+ } ,
205
+ response : { }
206
+ } ) ) ;
207
+ expect ( err . message ) . to . deep . equal ( 'Unknown Modifier(s) detected: jsonStringify, toBase64' ) ;
207
208
} ) ;
208
209
209
- it ( 'Testing unknown modifiers (nested)' , async ( { recorder } ) => {
210
+ it ( 'Testing unknown modifiers (nested)' , async ( { capture } ) => {
210
211
prepareCassette ( {
211
212
response : { } ,
212
213
body : {
@@ -215,18 +216,17 @@ describe('Testing RequestRecorder', { useTmpDir: true, timestamp: 0 }, () => {
215
216
}
216
217
}
217
218
} ) ;
218
- await validate ( {
219
+
220
+ const err = await capture ( ( ) => validate ( {
219
221
json : true ,
220
222
body : {
221
- ' payload|jsonStringify|toBase64' : {
223
+ payload : {
222
224
key : 'value'
223
225
}
224
226
} ,
225
227
response : { }
226
- } ) ;
227
- expect ( recorder . get ( ) ) . to . deep . equal ( [
228
- 'Unknown Modifier(s) detected: jsonStringify, toBase64'
229
- ] ) ;
228
+ } ) ) ;
229
+ expect ( err . message ) . to . deep . equal ( 'Unknown Modifier(s) detected: jsonStringify, toBase64' ) ;
230
230
} ) ;
231
231
} ) ;
232
232
@@ -317,6 +317,41 @@ describe('Testing RequestRecorder', { useTmpDir: true, timestamp: 0 }, () => {
317
317
await runner ( 'body' , { body : null } ) ;
318
318
} ) ;
319
319
320
+ it ( 'Testing body healing with missing body' , async ( ) => {
321
+ await runner ( 'body' , {
322
+ body : { } ,
323
+ cassetteContent : [
324
+ {
325
+ scope : server . uri ,
326
+ method : 'GET' ,
327
+ path : '/?q=1' ,
328
+ status : 200 ,
329
+ reqheaders : { } ,
330
+ response : { data : '1' } ,
331
+ responseIsBinary : false
332
+ }
333
+ ]
334
+ } ) ;
335
+ } ) ;
336
+
337
+ it ( 'Testing missing body error' , async ( { capture } ) => {
338
+ const err = await capture ( ( ) => runner ( false , {
339
+ body : { } ,
340
+ cassetteContent : [
341
+ {
342
+ scope : server . uri ,
343
+ method : 'GET' ,
344
+ path : '/?q=1' ,
345
+ status : 200 ,
346
+ reqheaders : { } ,
347
+ response : { data : '1' } ,
348
+ responseIsBinary : false
349
+ }
350
+ ]
351
+ } ) ) ;
352
+ expect ( err . message ) . to . deep . equal ( 'Recording body mismatch' ) ;
353
+ } ) ;
354
+
320
355
it ( 'Testing body healing with mismatched request method' , async ( ) => {
321
356
await runner ( 'body' , { raises : true , heals : false , method : 'POST' } ) ;
322
357
} ) ;
0 commit comments