apify-test-tools 0.4.0 → 0.5.0

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/lib/consts.ts CHANGED
@@ -12,4 +12,5 @@ export const TO_FINISH_WITH_OPTIONS: ToFinishWithOptionsWithDefaults = {
12
12
  'ReferenceError',
13
13
  'TypeError',
14
14
  ],
15
+ maxRetriesPerRequest: null,
15
16
  };
@@ -145,7 +145,7 @@ export const extendExpect = (expect: ExpectStatic): ExpectStatic => {
145
145
 
146
146
  const checkInterval = (
147
147
  value: number | undefined,
148
- key: ['datasetItemCount', 'duration', 'failedRequests', 'requestsRetries'][number],
148
+ key: ['datasetItemCount', 'duration', 'failedRequests', 'requestsRetries', 'maxRetriesPerRequest'][number],
149
149
  label: string,
150
150
  ) => {
151
151
  const result = isWithinInterval(diffs, value, options, key);
@@ -158,6 +158,8 @@ export const extendExpect = (expect: ExpectStatic): ExpectStatic => {
158
158
  checkInterval(durationMillis, 'duration', 'duration');
159
159
  checkInterval(stats?.requestsFailed, 'failedRequests', 'failed requests');
160
160
  checkInterval(stats?.requestsRetries, 'requestsRetries', 'requests retries');
161
+ const maxRetriesObserved = (stats?.requestRetryHistogram ?? [0]).length - 1;
162
+ checkInterval(maxRetriesObserved, 'maxRetriesPerRequest', 'max retries per request');
161
163
 
162
164
  const ppeDiffs: Diffs = {
163
165
  pass: true,
package/lib/types.ts CHANGED
@@ -46,6 +46,7 @@ export type ToFinishWithOptionsWithDefaults = {
46
46
  failedRequests: Interval | null
47
47
  requestsRetries: Interval | null
48
48
  forbiddenLogs: string[]
49
+ maxRetriesPerRequest: number | null
49
50
  }
50
51
  export type IntervalOption<PpeEvent extends string> = keyof Pick<
51
52
  ToFinishWithOptions<PpeEvent>,
@@ -123,6 +124,7 @@ export interface ActorMatchers<R = unknown> {
123
124
  * - `failedRequests` (default: `0`)
124
125
  * - `requestsRetries` (default: `{ max: 3 }`)
125
126
  * - `forbiddenLogs` (default: `['ReferenceError', 'TypeError']`)
127
+ * - `maxRetriesPerRequest` (not checked by default)
126
128
  * - `datasetItemCount` (required)
127
129
  * - `chargedEventCounts`
128
130
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apify-test-tools",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "TBD",
6
6
  "engines": {