twd-js 1.4.3 → 1.5.1

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/index.d.ts CHANGED
@@ -102,6 +102,7 @@ declare interface Options {
102
102
  status?: number;
103
103
  responseHeaders?: Record<string, string>;
104
104
  urlRegex?: boolean;
105
+ delay?: number;
105
106
  }
106
107
 
107
108
  declare type Rule = {
@@ -114,6 +115,8 @@ declare type Rule = {
114
115
  status?: number;
115
116
  responseHeaders?: Record<string, string>;
116
117
  urlRegex?: boolean;
118
+ delay?: number;
119
+ hitCount?: number;
117
120
  };
118
121
 
119
122
  declare type ScreenDom = typeof screen_2;
@@ -270,6 +273,7 @@ declare interface TWDAPI {
270
273
  * - `response`: Body of the mocked response
271
274
  * - `status`: (optional) HTTP status code (default: 200)
272
275
  * - `responseHeaders`: (optional) Response headers
276
+ * - `delay`: (optional) Delay in ms before returning the response
273
277
  *
274
278
  * @example
275
279
  * ```ts
@@ -353,6 +357,29 @@ declare interface TWDAPI {
353
357
  * ```
354
358
  */
355
359
  getRequestMockRules: () => Rule[];
360
+ /**
361
+ * Gets the number of times a specific mock rule was hit.
362
+ * @param alias The alias of the mock rule
363
+ * @returns The number of times the rule was matched
364
+ *
365
+ * @example
366
+ * ```ts
367
+ * const count = twd.getRequestCount("getUser");
368
+ * expect(count).to.equal(2);
369
+ * ```
370
+ */
371
+ getRequestCount: (alias: string) => number;
372
+ /**
373
+ * Gets a snapshot of all mock rule hit counts.
374
+ * @returns An object mapping rule aliases to their hit counts
375
+ *
376
+ * @example
377
+ * ```ts
378
+ * const counts = twd.getRequestCounts();
379
+ * expect(counts).to.deep.equal({ getUser: 2, listPosts: 1 });
380
+ * ```
381
+ */
382
+ getRequestCounts: () => Record<string, number>;
356
383
  /**
357
384
  * Waits for a specified time.
358
385
  * @param time Time in milliseconds to wait