@zimic/interceptor 0.19.1-canary.6 → 0.19.1-canary.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/http.d.ts CHANGED
@@ -114,21 +114,13 @@ type HttpRequestHandlerResponseDeclarationWithHeaders<ResponseSchema extends Htt
114
114
  } : {
115
115
  headers: HttpRequestHandlerResponseDeclarationHeaders<ResponseSchema>;
116
116
  };
117
- /** A declaration of an HTTP response for an intercepted request. */
117
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */
118
118
  type HttpRequestHandlerResponseDeclaration<MethodSchema extends HttpMethodSchema = HttpMethodSchema, StatusCode extends HttpStatusCode = HttpStatusCode> = StatusCode extends StatusCode ? {
119
119
  status: StatusCode;
120
120
  } & HttpRequestHandlerResponseWithBody<Default<Default<MethodSchema['response']>[StatusCode]>, StatusCode> & HttpRequestHandlerResponseDeclarationWithHeaders<Default<Default<MethodSchema['response']>[StatusCode]>> : never;
121
- /**
122
- * A factory to create {@link HttpRequestHandlerResponseDeclaration} objects.
123
- *
124
- * @param request The intercepted request.
125
- * @returns The response declaration.
126
- */
121
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */
127
122
  type HttpRequestHandlerResponseDeclarationFactory<Path extends string, MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode = HttpStatusCode> = (request: Omit<HttpInterceptorRequest<Path, MethodSchema>, 'response'>) => PossiblePromise<HttpRequestHandlerResponseDeclaration<MethodSchema, StatusCode>>;
128
- /**
129
- * A strict representation of an intercepted HTTP request. The body, search params and path params are already parsed by
130
- * default.
131
- */
123
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
132
124
  interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema> extends Omit<HttpRequest, keyof Body | 'headers' | 'clone'> {
133
125
  /** The headers of the request. */
134
126
  headers: HttpHeaders<Default<HttpRequestHeadersSchema<MethodSchema>>>;
@@ -141,10 +133,7 @@ interface HttpInterceptorRequest<Path extends string, MethodSchema extends HttpM
141
133
  /** The raw request object. */
142
134
  raw: HttpRequest<HttpRequestBodySchema<MethodSchema>, Default<HttpRequestHeadersSchema<MethodSchema>>>;
143
135
  }
144
- /**
145
- * A strict representation of an intercepted HTTP response. The body, search params and path params are already parsed
146
- * by default.
147
- */
136
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
148
137
  interface HttpInterceptorResponse<MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode> extends Omit<HttpResponse, keyof Body | 'headers' | 'clone'> {
149
138
  /** The headers of the response. */
150
139
  headers: HttpHeaders<Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>>;
@@ -155,10 +144,7 @@ interface HttpInterceptorResponse<MethodSchema extends HttpMethodSchema, StatusC
155
144
  /** The raw response object. */
156
145
  raw: HttpResponse<HttpResponseBodySchema<MethodSchema, StatusCode>, Default<HttpResponseHeadersSchema<MethodSchema, StatusCode>>, StatusCode>;
157
146
  }
158
- /**
159
- * A strict representation of an intercepted HTTP request, along with its response. The body, search params and path
160
- * params are already parsed by default.
161
- */
147
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference} */
162
148
  interface InterceptedHttpInterceptorRequest<Path extends string, MethodSchema extends HttpMethodSchema, StatusCode extends HttpStatusCode = never> extends HttpInterceptorRequest<Path, MethodSchema> {
163
149
  /** The response that was returned for the intercepted request. */
164
150
  response: StatusCode extends [never] ? never : HttpInterceptorResponse<MethodSchema, StatusCode>;
@@ -240,64 +226,28 @@ interface RemoteHttpInterceptorOptions extends SharedHttpInterceptorOptions {
240
226
  type HttpInterceptorOptions = LocalHttpInterceptorOptions | RemoteHttpInterceptorOptions;
241
227
 
242
228
  type PartialHttpHeadersOrSchema<Schema extends HttpHeadersSchema.Loose> = IfNever<Schema, never, Partial<Schema> | HttpHeaders<Partial<Schema>> | HttpHeaders<Schema>>;
243
- /**
244
- * A static headers restriction to match intercepted requests.
245
- *
246
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
247
- */
229
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
248
230
  type HttpRequestHandlerHeadersStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = PartialHttpHeadersOrSchema<Default<HttpRequestHeadersSchema<Default<Schema[Path][Method]>>>>;
249
231
  type PartialHttpSearchParamsOrSchema<Schema extends HttpSearchParamsSchema.Loose> = IfNever<Schema, never, Partial<Schema> | HttpSearchParams<Partial<Schema>> | HttpSearchParams<Schema>>;
250
- /**
251
- * A static search params restriction to match intercepted requests.
252
- *
253
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
254
- */
232
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
255
233
  type HttpRequestHandlerSearchParamsStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = PartialHttpSearchParamsOrSchema<Default<HttpRequestSearchParamsSchema<Default<Schema[Path][Method]>>>>;
256
234
  type PartialBodyOrSchema<Body extends HttpBody> = Body extends HttpFormData<infer Schema> ? HttpFormData<Partial<Schema>> | HttpFormData<Schema> : Body extends HttpSearchParams<infer Schema> ? HttpSearchParams<Partial<Schema>> | HttpSearchParams<Schema> : Body extends Blob ? Body : DeepPartial<Body>;
257
- /**
258
- * A static body restriction to match intercepted requests.
259
- *
260
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
261
- */
235
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
262
236
  type HttpRequestHandlerBodyStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = PartialBodyOrSchema<HttpRequestBodySchema<Default<Schema[Path][Method]>>>;
263
- /**
264
- * A static restriction to match intercepted requests.
265
- *
266
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
267
- */
237
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
268
238
  interface HttpRequestHandlerStaticRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> {
269
- /**
270
- * A set of headers that the intercepted request must contain to match the handler. If exact is `true`, the request
271
- * must contain exactly these headers and no others.
272
- */
239
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
273
240
  headers?: HttpRequestHandlerHeadersStaticRestriction<Schema, Method, Path>;
274
- /**
275
- * A set of search params that the intercepted request must contain to match the handler. If exact is `true`, the
276
- * request must contain exactly these search params and no others.
277
- */
241
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
278
242
  searchParams?: HttpRequestHandlerSearchParamsStaticRestriction<Schema, Method, Path>;
279
- /**
280
- * The body that the intercepted request must contain to match the handler. If exact is `true`, the request must
281
- * contain exactly this body and no other.
282
- */
243
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
283
244
  body?: HttpRequestHandlerBodyStaticRestriction<Schema, Method, Path>;
284
- /**
285
- * If `true`, the request must contain **exactly** the headers, search params, and body declared in this restriction.
286
- * Otherwise, the request must contain **at least** them.
287
- */
245
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
288
246
  exact?: boolean;
289
247
  }
290
- /**
291
- * A computed restriction to match intercepted requests.
292
- *
293
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
294
- */
248
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
295
249
  type HttpRequestHandlerComputedRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = (request: HttpInterceptorRequest<Path, Default<Schema[Path][Method]>>) => PossiblePromise<boolean>;
296
- /**
297
- * A restriction to match intercepted requests.
298
- *
299
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
300
- */
250
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
301
251
  type HttpRequestHandlerRestriction<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> = HttpRequestHandlerStaticRestriction<Schema, Method, Path> | HttpRequestHandlerComputedRestriction<Schema, Method, Path>;
302
252
  interface RestrictionDiff<Value> {
303
253
  expected: Value;
@@ -314,143 +264,34 @@ interface UnmatchedHttpInterceptorRequestGroup {
314
264
  diff: RestrictionDiffs;
315
265
  }
316
266
 
317
- /**
318
- * An HTTP request handler to declare responses for intercepted requests.
319
- *
320
- * When multiple handlers of the same interceptor match the same method and path, the _last_ handler created with
321
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptormethodpath `interceptor.<method>(path)`}
322
- * will be used.
323
- *
324
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler` API reference}
325
- */
267
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler` API reference} */
326
268
  interface HttpRequestHandler<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>> {
327
269
  /**
328
- * The method that matches this handler.
329
- *
330
270
  * @readonly
331
271
  * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlermethod `handler.method` API reference}
332
272
  */
333
273
  get method(): Method;
334
274
  /**
335
- * The path that matches this handler. The base URL of the interceptor is not included, but it is used when matching
336
- * requests.
337
- *
338
275
  * @readonly
339
276
  * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerpath `handler.path` API reference}
340
277
  */
341
278
  get path(): Path;
342
279
  }
343
- /**
344
- * A local HTTP request handler to declare responses for intercepted requests. In a local handler, the mocking
345
- * operations are synchronous and are executed in the same process where it was created.
346
- *
347
- * When multiple handlers of the same interceptor match the same method and path, the _last_ handler created with
348
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptormethodpath `interceptor.<method>(path)`}
349
- * will be used.
350
- *
351
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler` API reference}
352
- */
280
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler `HttpRequestHandler` API reference} */
353
281
  interface LocalHttpRequestHandler<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>, StatusCode extends HttpStatusCode = never> extends HttpRequestHandler<Schema, Method, Path> {
354
282
  /** @readonly */
355
283
  get type(): 'local';
356
- /**
357
- * Declares a restriction to intercepted request matches. `headers`, `searchParams`, and `body` are supported to limit
358
- * which requests will match the handler and receive the mock response. If multiple restrictions are declared, either
359
- * in a single object or with multiple calls to `handler.with()`, all of them must be met, essentially creating an AND
360
- * condition.
361
- *
362
- * By default, restrictions use `exact: false`, meaning that any request **containing** the declared restrictions will
363
- * match the handler, regardless of having more properties or values. If you want to match only requests with the
364
- * exact values declared, you can use `exact: true`.
365
- *
366
- * A function is also supported to declare restrictions, in case they are dynamic.
367
- *
368
- * @param restriction The restriction to match intercepted requests.
369
- * @returns The same handler, now considering the specified restriction.
370
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
371
- */
284
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
372
285
  with: (restriction: HttpRequestHandlerRestriction<Schema, Method, Path>) => this;
373
- /**
374
- * Declares a response to return for matched intercepted requests.
375
- *
376
- * When the handler matches a request, it will respond with the given declaration. The response type is statically
377
- * validated against the schema of the interceptor.
378
- *
379
- * @param declaration The response declaration or a factory to create it.
380
- * @returns The same handler, now including type information about the response declaration based on the specified
381
- * status code.
382
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference}
383
- */
286
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */
384
287
  respond: <NewStatusCode extends HttpResponseSchemaStatusCode<Default<Default<Schema[Path][Method]>['response']>>>(declaration: HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode> | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>) => LocalHttpRequestHandler<Schema, Method, Path, NewStatusCode>;
385
- /**
386
- * Declares a number of intercepted requests that the handler will be able to match and return its response.
387
- *
388
- * If only one argument is provided, the handler will match exactly that number of requests. In case of two arguments,
389
- * the handler will consider an inclusive range, matching at least the minimum (first argument) and at most the
390
- * maximum (second argument) number of requests.
391
- *
392
- * Once the handler receives more requests than the maximum number declared, it will stop matching requests and
393
- * returning its response. In this case, Zimic will try other handlers until one eligible is found, otherwise the
394
- * request will be either bypassed or rejected. Learn more about how Zimic decides which handler to use for an
395
- * intercepted request in the
396
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}.
397
- *
398
- * **Important**: To make sure that all expected requests were made, use
399
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorchecktimes `interceptor.checkTimes()`} or
400
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()`}.
401
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorchecktimes `interceptor.checkTimes()`} is
402
- * generally preferred, as it checks all handlers created by the interceptor with a single call.
403
- *
404
- * @param numberOfRequests The number of times the handler should match intercepted requests.
405
- * @param minNumberOfRequests The minimum number of times the handler should match intercepted requests.
406
- * @param maxNumberOfRequests The maximum number of times the handler should match intercepted requests.
407
- * @returns The same handler, now considering the specified number of times.
408
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference}
409
- */
288
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference} */
410
289
  times: ((numberOfRequests: number) => this) & ((minNumberOfRequests: number, maxNumberOfRequests: number) => this);
411
- /**
412
- * Checks if the handler has matched the expected number of requests declared with
413
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()`}.
414
- *
415
- * If the handler has matched fewer or more requests than expected, this method will throw a `TimesCheckError` error
416
- * pointing to the
417
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference}
418
- * that was not satisfied.
419
- *
420
- * When {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `requestSaving.enabled`} is `true` in
421
- * your interceptor, the `TimesCheckError` errors will also list each unmatched request with diff of the expected and
422
- * received data. This is useful for debugging requests that did not match a handler with
423
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}.
424
- *
425
- * @throws {TimesCheckError} If the handler has matched less or more requests than the expected number of requests.
426
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerchecktimes `handler.checkTimes()` API reference}
427
- */
290
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerchecktimes `handler.checkTimes()` API reference} */
428
291
  checkTimes: () => void;
429
- /**
430
- * Clears any response declared with
431
- * [`handler.respond(declaration)`](https://zimic.dev/docs/interceptor/api/http-request-handler#handlerresponddeclaration),
432
- * restrictions declared with
433
- * [`handler.with(restriction)`](https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction),
434
- * and intercepted requests, making the handler stop matching requests. The next handler, created before this one,
435
- * that matches the same method and path will be used if present. If not, the requests of the method and path will not
436
- * be intercepted.
437
- *
438
- * To make the handler match requests again, register a new response with
439
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()`}.
440
- *
441
- * @returns The same handler, now cleared of any declared responses, restrictions, and intercepted requests.
442
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerclear `handler.clear()` API reference}
443
- */
292
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerclear `handler.clear()` API reference} */
444
293
  clear: () => this;
445
294
  /**
446
- * The intercepted requests that matched this handler, along with the responses returned to each of them. This is
447
- * useful for testing that the correct requests were made by your application.
448
- *
449
- * **Important**: This method can only be used if
450
- * {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `requestSaving.enabled`} is `true` in the
451
- * interceptor.
452
- *
453
- * @throws {DisabledRequestSavingError} If the interceptor has `requestSaving.enabled: false`.
454
295
  * @readonly
455
296
  * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference}
456
297
  */
@@ -465,104 +306,17 @@ interface LocalHttpRequestHandler<Schema extends HttpSchema, Method extends Http
465
306
  interface SyncedRemoteHttpRequestHandler<Schema extends HttpSchema, Method extends HttpSchemaMethod<Schema>, Path extends HttpSchemaPath<Schema, Method>, StatusCode extends HttpStatusCode = never> extends HttpRequestHandler<Schema, Method, Path> {
466
307
  /** @readonly */
467
308
  get type(): 'remote';
468
- /**
469
- * Declares a restriction to intercepted request matches. `headers`, `searchParams`, and `body` are supported to limit
470
- * which requests will match the handler and receive the mock response. If multiple restrictions are declared, either
471
- * in a single object or with multiple calls to `handler.with()`, all of them must be met, essentially creating an AND
472
- * condition.
473
- *
474
- * By default, restrictions use `exact: false`, meaning that any request **containing** the declared restrictions will
475
- * match the handler, regardless of having more properties or values. If you want to match only requests with the
476
- * exact values declared, you can use `exact: true`.
477
- *
478
- * A function is also supported to declare restrictions, in case they are dynamic.
479
- *
480
- * @param restriction The restriction to match intercepted requests.
481
- * @returns The same handler, now considering the specified restriction.
482
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference}
483
- */
309
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction `handler.with()` API reference} */
484
310
  with: (restriction: HttpRequestHandlerRestriction<Schema, Method, Path>) => PendingRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>;
485
- /**
486
- * Declares a response to return for matched intercepted requests.
487
- *
488
- * When the handler matches a request, it will respond with the given declaration. The response type is statically
489
- * validated against the schema of the interceptor.
490
- *
491
- * @param declaration The response declaration or a factory to create it.
492
- * @returns The same handler, now including type information about the response declaration based on the specified
493
- * status code.
494
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference}
495
- */
311
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()` API reference} */
496
312
  respond: <NewStatusCode extends HttpResponseSchemaStatusCode<Default<Default<Schema[Path][Method]>['response']>>>(declaration: HttpRequestHandlerResponseDeclaration<Default<Schema[Path][Method]>, NewStatusCode> | HttpRequestHandlerResponseDeclarationFactory<Path, Default<Schema[Path][Method]>, NewStatusCode>) => PendingRemoteHttpRequestHandler<Schema, Method, Path, NewStatusCode>;
497
- /**
498
- * Declares a number of intercepted requests that the handler will be able to match and return its response.
499
- *
500
- * If only one argument is provided, the handler will match exactly that number of requests. In case of two arguments,
501
- * the handler will consider an inclusive range, matching at least the minimum (first argument) and at most the
502
- * maximum (second argument) number of requests.
503
- *
504
- * Once the handler receives more requests than the maximum number declared, it will stop matching requests and
505
- * returning its response. In this case, Zimic will try other handlers until one eligible is found, otherwise the
506
- * request will be either bypassed or rejected. Learn more about how Zimic decides which handler to use for an
507
- * intercepted request in the
508
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#declaring-request-handlers Declaring request handlers}.
509
- *
510
- * **Important**: To make sure that all expected requests were made, use
511
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorchecktimes `interceptor.checkTimes()`} or
512
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerchecktimes `handler.checkTimes()`}.
513
- * {@link https://zimic.dev/docs/interceptor/api/http-interceptor#interceptorchecktimes `interceptor.checkTimes()`} is
514
- * generally preferred, as it checks all handlers created by the interceptor with a single call.
515
- *
516
- * @param numberOfRequests The number of times the handler should match intercepted requests.
517
- * @param minNumberOfRequests The minimum number of times the handler should match intercepted requests.
518
- * @param maxNumberOfRequests The maximum number of times the handler should match intercepted requests.
519
- * @returns The same handler, now considering the specified number of times.
520
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference}
521
- */
313
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference} */
522
314
  times: ((numberOfRequests: number) => PendingRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>) & ((minNumberOfRequests: number, maxNumberOfRequests: number) => PendingRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>);
523
- /**
524
- * Checks if the handler has matched the expected number of requests declared with
525
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()`}.
526
- *
527
- * If the handler has matched fewer or more requests than expected, this method will throw a `TimesCheckError` error
528
- * pointing to the
529
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlertimes `handler.times()` API reference}
530
- * that was not satisfied.
531
- *
532
- * When {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `requestSaving.enabled`} is true in your
533
- * interceptor, the `TimesCheckError` errors will also list each unmatched request with diff of the expected and
534
- * received data. This is useful for debugging requests that did not match a handler with
535
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction restrictions}.
536
- *
537
- * @throws {TimesCheckError} If the handler has matched less or more requests than the expected number of requests.
538
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerchecktimes `handler.checkTimes()` API reference}
539
- */
315
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerchecktimes `handler.checkTimes()` API reference} */
540
316
  checkTimes: () => Promise<void>;
541
- /**
542
- * Clears any response declared with
543
- * [`handler.respond(declaration)`](https://zimic.dev/docs/interceptor/api/http-request-handler#handlerresponddeclaration),
544
- * restrictions declared with
545
- * [`handler.with(restriction)`](https://zimic.dev/docs/interceptor/api/http-request-handler#handlerwithrestriction),
546
- * and intercepted requests, making the handler stop matching requests. The next handler, created before this one,
547
- * that matches the same method and path will be used if present. If not, the requests of the method and path will not
548
- * be intercepted.
549
- *
550
- * To make the handler match requests again, register a new response with
551
- * {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrespond `handler.respond()`}.
552
- *
553
- * @returns The same handler, now cleared of any declared responses, restrictions, and intercepted requests.
554
- * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerclear `handler.clear()` API reference}
555
- */
317
+ /** @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerclear `handler.clear()` API reference} */
556
318
  clear: () => PendingRemoteHttpRequestHandler<Schema, Method, Path, StatusCode>;
557
319
  /**
558
- * The intercepted requests that matched this handler, along with the responses returned to each of them. This is
559
- * useful for testing that the correct requests were made by your application.
560
- *
561
- * **Important**: This method can only be used if
562
- * {@link https://zimic.dev/docs/interceptor/api/create-http-interceptor `requestSaving.enabled`} is `true` in the
563
- * interceptor.
564
- *
565
- * @throws {DisabledRequestSavingError} If the interceptor has `requestSaving.enabled: false`.
566
320
  * @readonly
567
321
  * @see {@link https://zimic.dev/docs/interceptor/api/http-request-handler#handlerrequests `handler.requests` API reference}
568
322
  */