@@ -214,55 +214,65 @@ expectError(expect(jest.fn()).toHaveBeenCalledTimes());
214
214
expectType < void > ( expect ( jest . fn ( ) ) . toBeCalledWith ( ) ) ;
215
215
expectType < void > ( expect ( jest . fn ( ) ) . toBeCalledWith ( 'value' ) ) ;
216
216
expectType < void > ( expect ( jest . fn ( ) ) . toBeCalledWith ( 'value' , 123 ) ) ;
217
+ expectType < void > (
218
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . toBeCalledWith (
219
+ expect . stringContaining ( 'value' ) ,
220
+ 123 ,
221
+ ) ,
222
+ ) ;
223
+
217
224
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenCalledWith ( ) ) ;
218
225
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenCalledWith ( 123 ) ) ;
219
226
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenCalledWith ( 123 , 'value' ) ) ;
220
-
221
- /**
222
- * type inference for "CalledWith" matchers parameters
223
- */
224
- expectError ( expect ( jest . fn < ( a : string ) => void > ( ) ) . toHaveBeenCalledWith ( 123 ) ) ;
225
- expectError (
226
- expect ( jest . fn < ( a : string ) => void > ( ) ) . toHaveBeenNthCalledWith ( 1 , 123 ) ,
227
- ) ;
228
- expectError (
229
- expect ( jest . fn < ( a : string ) => void > ( ) ) . toHaveBeenLastCalledWith ( 123 ) ,
230
- ) ;
231
- expectType < void > (
232
- expect (
233
- jest . fn < ( a : string , b : number , c ?: boolean ) => void > ( ) ,
234
- ) . toHaveBeenCalledWith ( 'value' , 123 ) ,
235
- ) ;
236
227
expectType < void > (
237
- expect (
238
- jest . fn < ( a : string , b : number , c ?: boolean ) => void > ( ) ,
239
- ) . toHaveBeenCalledWith ( 'value' , 123 , true ) ,
240
- ) ;
241
- expectError (
242
- expect (
243
- jest . fn < ( a : string , b : number , c ?: boolean ) => void > ( ) ,
244
- ) . toHaveBeenCalledWith ( 123 , 'value' ) ,
245
- ) ;
246
- expectError (
247
- expect (
248
- jest . fn < ( a : string , b : number , c ?: boolean ) => void > ( ) ,
249
- ) . toHaveBeenCalledWith ( 'value' , 123 , 'not a boolean' ) ,
228
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . toHaveBeenCalledWith (
229
+ expect . stringContaining ( 'value' ) ,
230
+ 123 ,
231
+ ) ,
250
232
) ;
251
233
252
234
expectType < void > ( expect ( jest . fn ( ) ) . lastCalledWith ( ) ) ;
253
235
expectType < void > ( expect ( jest . fn ( ) ) . lastCalledWith ( 'value' ) ) ;
254
236
expectType < void > ( expect ( jest . fn ( ) ) . lastCalledWith ( 'value' , 123 ) ) ;
237
+ expectType < void > (
238
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . lastCalledWith (
239
+ expect . stringContaining ( 'value' ) ,
240
+ 123 ,
241
+ ) ,
242
+ ) ;
243
+
255
244
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenLastCalledWith ( ) ) ;
256
245
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenLastCalledWith ( 123 ) ) ;
257
246
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenLastCalledWith ( 123 , 'value' ) ) ;
247
+ expectType < void > (
248
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . lastCalledWith (
249
+ expect . stringContaining ( 'value' ) ,
250
+ 123 ,
251
+ ) ,
252
+ ) ;
258
253
259
254
expectType < void > ( expect ( jest . fn ( ) ) . nthCalledWith ( 2 ) ) ;
260
255
expectType < void > ( expect ( jest . fn ( ) ) . nthCalledWith ( 1 , 'value' ) ) ;
261
256
expectType < void > ( expect ( jest . fn ( ) ) . nthCalledWith ( 1 , 'value' , 123 ) ) ;
257
+ expectType < void > (
258
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . nthCalledWith (
259
+ 1 ,
260
+ expect . stringContaining ( 'value' ) ,
261
+ 123 ,
262
+ ) ,
263
+ ) ;
262
264
expectError ( expect ( jest . fn ( ) ) . nthCalledWith ( ) ) ;
265
+
263
266
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenNthCalledWith ( 2 ) ) ;
264
267
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenNthCalledWith ( 1 , 'value' ) ) ;
265
268
expectType < void > ( expect ( jest . fn ( ) ) . toHaveBeenNthCalledWith ( 1 , 'value' , 123 ) ) ;
269
+ expectType < void > (
270
+ expect ( jest . fn < ( a : string , b : number ) => void > ( ) ) . toHaveBeenNthCalledWith (
271
+ 1 ,
272
+ expect . stringContaining ( 'value' ) ,
273
+ 123 ,
274
+ ) ,
275
+ ) ;
266
276
expectError ( expect ( jest . fn ( ) ) . toHaveBeenNthCalledWith ( ) ) ;
267
277
268
278
expectType < void > ( expect ( jest . fn ( ) ) . toReturn ( ) ) ;
@@ -278,43 +288,55 @@ expectError(expect(jest.fn()).toHaveReturnedTimes(true));
278
288
expectError ( expect ( jest . fn ( ) ) . toHaveReturnedTimes ( ) ) ;
279
289
280
290
expectType < void > ( expect ( jest . fn ( ) ) . toReturnWith ( 'value' ) ) ;
281
- expectType < void > ( expect ( jest . fn < ( ) => string > ( ) ) . toReturnWith ( 'value' ) ) ;
282
- expectError ( expect ( jest . fn < ( ) => number > ( ) ) . toReturnWith ( 'value' ) ) ;
283
- expectError ( expect ( 123 ) . toReturnWith ( 'value' ) ) ;
291
+ expectType < void > (
292
+ expect ( jest . fn < ( ) => string > ( ) ) . toReturnWith (
293
+ expect . stringContaining ( 'value' ) ,
294
+ ) ,
295
+ ) ;
284
296
expectError ( expect ( jest . fn ( ) ) . toReturnWith ( ) ) ;
285
297
286
298
expectType < void > ( expect ( jest . fn ( ) ) . toHaveReturnedWith ( 123 ) ) ;
287
- expectType < void > ( expect ( jest . fn < ( ) => number > ( ) ) . toHaveReturnedWith ( 123 ) ) ;
288
- expectError ( expect ( jest . fn < ( ) => string > ( ) ) . toHaveReturnedWith ( 123 ) ) ;
289
- expectError ( expect ( 123 ) . toHaveReturnedWith ( 123 ) ) ;
299
+ expectType < void > (
300
+ expect ( jest . fn < ( ) => string > ( ) ) . toHaveReturnedWith (
301
+ expect . stringContaining ( 'value' ) ,
302
+ ) ,
303
+ ) ;
290
304
expectError ( expect ( jest . fn ( ) ) . toHaveReturnedWith ( ) ) ;
291
305
292
306
expectType < void > ( expect ( jest . fn ( ) ) . lastReturnedWith ( 'value' ) ) ;
293
- expectType < void > ( expect ( jest . fn < ( ) => string > ( ) ) . lastReturnedWith ( 'value' ) ) ;
294
- expectError ( expect ( jest . fn < ( ) => number > ( ) ) . lastReturnedWith ( 'value' ) ) ;
295
- expectError ( expect ( 123 ) . lastReturnedWith ( 'value' ) ) ;
307
+ expectType < void > (
308
+ expect ( jest . fn < ( ) => string > ( ) ) . lastReturnedWith (
309
+ expect . stringContaining ( 'value' ) ,
310
+ ) ,
311
+ ) ;
296
312
expectError ( expect ( jest . fn ( ) ) . lastReturnedWith ( ) ) ;
297
313
298
314
expectType < void > ( expect ( jest . fn ( ) ) . toHaveLastReturnedWith ( 123 ) ) ;
299
- expectType < void > ( expect ( jest . fn < ( ) => number > ( ) ) . toHaveLastReturnedWith ( 123 ) ) ;
300
- expectError ( expect ( jest . fn < ( ) => string > ( ) ) . toHaveLastReturnedWith ( 123 ) ) ;
301
- expectError ( expect ( 123 ) . toHaveLastReturnedWith ( 123 ) ) ;
315
+ expectType < void > (
316
+ expect ( jest . fn < ( ) => string > ( ) ) . toHaveLastReturnedWith (
317
+ expect . stringContaining ( 'value' ) ,
318
+ ) ,
319
+ ) ;
302
320
expectError ( expect ( jest . fn ( ) ) . toHaveLastReturnedWith ( ) ) ;
303
321
304
322
expectType < void > ( expect ( jest . fn ( ) ) . nthReturnedWith ( 1 , 'value' ) ) ;
305
- expectType < void > ( expect ( jest . fn < ( ) => string > ( ) ) . nthReturnedWith ( 2 , 'value' ) ) ;
306
- expectError ( expect ( jest . fn < ( ) => number > ( ) ) . nthReturnedWith ( 3 , 'value' ) ) ;
307
- expectError ( expect ( 123 ) . nthReturnedWith ( 4 , 'value' ) ) ;
308
- expectError ( expect ( 123 ) . nthReturnedWith ( 5 ) ) ;
323
+ expectType < void > (
324
+ expect ( jest . fn < ( ) => string > ( ) ) . nthReturnedWith (
325
+ 2 ,
326
+ expect . stringContaining ( 'value' ) ,
327
+ ) ,
328
+ ) ;
329
+ expectError ( expect ( 123 ) . nthReturnedWith ( 3 ) ) ;
309
330
expectError ( expect ( jest . fn ( ) ) . nthReturnedWith ( ) ) ;
310
331
311
- expectType < void > ( expect ( jest . fn ( ) ) . toHaveNthReturnedWith ( 1 , 'value' ) ) ;
332
+ expectType < void > ( expect ( jest . fn ( ) ) . nthReturnedWith ( 1 , 'value' ) ) ;
312
333
expectType < void > (
313
- expect ( jest . fn < ( ) => string > ( ) ) . toHaveNthReturnedWith ( 2 , 'value' ) ,
334
+ expect ( jest . fn < ( ) => string > ( ) ) . nthReturnedWith (
335
+ 2 ,
336
+ expect . stringContaining ( 'value' ) ,
337
+ ) ,
314
338
) ;
315
- expectError ( expect ( jest . fn < ( ) => number > ( ) ) . toHaveNthReturnedWith ( 3 , 'value' ) ) ;
316
- expectError ( expect ( 123 ) . toHaveNthReturnedWith ( 4 , 'value' ) ) ;
317
- expectError ( expect ( 123 ) . toHaveNthReturnedWith ( 5 ) ) ;
339
+ expectError ( expect ( 123 ) . toHaveNthReturnedWith ( 3 ) ) ;
318
340
expectError ( expect ( jest . fn ( ) ) . toHaveNthReturnedWith ( ) ) ;
319
341
320
342
// snapshot matchers
0 commit comments