apify-test-tools 0.9.0-beta.2 → 0.9.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
@@ -16,3 +16,10 @@ export const TO_FINISH_WITH_OPTIONS: ToFinishWithOptionsWithDefaults = {
16
16
  * Both the test runs and the vitest test specs should finish in this time - 1 hour
17
17
  */
18
18
  export const DEFAULT_TEST_RUN_DURATION_MS = 60 * 60 * 1000; // 1 hour
19
+
20
+ /**
21
+ * Delay before checking the dataset and statistics after a run finishes to resolve eventual consistency.
22
+ * - This value should ensure that the dataset and statistics are fully updated before any assertions are made.
23
+ * - Super rarely the platform is still not synced even after 10s, so 20s should be sufficient practically always.
24
+ */
25
+ export const DATASET_SYNC_DELAY_MS = 20 * 1000; // 20 seconds
package/lib/lib.ts CHANGED
@@ -3,7 +3,7 @@ import { ApifyClient } from 'apify-client';
3
3
  import type { SuiteFactory, TestContext, TestFunction } from 'vitest';
4
4
  import { describe as vitestDescribe, ExpectStatic, test as vitestTest } from 'vitest';
5
5
 
6
- import { DEFAULT_TEST_RUN_DURATION_MS } from './consts.js';
6
+ import { DATASET_SYNC_DELAY_MS, DEFAULT_TEST_RUN_DURATION_MS } from './consts.js';
7
7
  import { extendExpect } from './extend-expect.js';
8
8
  import { RunTestResult } from './run-test-result.js';
9
9
  import type { ActorBuild, ActorTestOptions, RunOptions } from './types.js';
@@ -286,8 +286,8 @@ const createStartRunFn = <T>(actorId: string, testContext: TestContext) => {
286
286
  actorId: actorConfig?.actorFullName ?? actorId,
287
287
  };
288
288
 
289
- // waiting for datasetItemCount and chargedEventCounts to sync
290
- await sleep(10_000);
289
+ // waiting for dataset and statistics to sync, the Apify platform is only eventually consistent.
290
+ await sleep(DATASET_SYNC_DELAY_MS);
291
291
 
292
292
  return new RunTestResult(apifyClient, run);
293
293
  };
package/package.json CHANGED
@@ -1,64 +1,64 @@
1
1
  {
2
- "name": "apify-test-tools",
3
- "version": "0.9.0-beta.2",
4
- "type": "module",
5
- "description": "TBD",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/apify/apify-test-tools.git"
9
- },
10
- "engines": {
11
- "node": ">=18.0.0"
12
- },
13
- "bin": {
14
- "apify-test-tools": "dist/bin/main.js"
15
- },
16
- "types": "./dist/index.d.ts",
17
- "main": "./dist/lib/lib.js",
18
- "dependencies": {
19
- "@apify/consts": "^2.43.0",
20
- "@slack/web-api": "^7.9.2",
21
- "apify-client": "^2.22.2",
22
- "ignore": "^7.0.5",
23
- "yargs": "^18.0.0"
24
- },
25
- "devDependencies": {
26
- "@apify/eslint-config": "^1.0.0",
27
- "@apify/tsconfig": "^0.1.1",
28
- "@types/node": "^24.0.0",
29
- "@types/yargs": "^17.0.33",
30
- "eslint": "^9.29.0",
31
- "eslint-config-prettier": "^10.1.5",
32
- "globals": "^17.0.0",
33
- "husky": "^9.0.11",
34
- "knip": "^5.65.0",
35
- "lint-staged": "^15.2.2",
36
- "prettier": "^3.5.3",
37
- "tsx": "^4.20.3",
38
- "typescript": "^5.9.3",
39
- "typescript-eslint": "^8.34.1",
40
- "vitest": "^3.2.4"
41
- },
42
- "peerDependencies": {
43
- "vitest": ">=3.2.4"
44
- },
45
- "scripts": {
46
- "start": "npm run dist/bin/main.js",
47
- "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
48
- "build": "tsc && chmod +x ./dist/bin/main.js",
49
- "lint": "eslint",
50
- "lint:fix": "eslint --fix",
51
- "format": "prettier --write .",
52
- "format:check": "prettier --check .",
53
- "type-check": "tsc --noEmit",
54
- "test": "vitest run",
55
- "check-unused": "npx knip",
56
- "prepare": "husky .husky || true"
57
- },
58
- "lint-staged": {
59
- "*.js": "eslint",
60
- "*.ts": "eslint"
61
- },
62
- "author": "oklinov",
63
- "license": "ISC"
2
+ "name": "apify-test-tools",
3
+ "version": "0.9.0",
4
+ "type": "module",
5
+ "description": "TBD",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/apify/apify-test-tools.git"
9
+ },
10
+ "engines": {
11
+ "node": ">=18.0.0"
12
+ },
13
+ "bin": {
14
+ "apify-test-tools": "dist/bin/main.js"
15
+ },
16
+ "types": "./dist/index.d.ts",
17
+ "main": "./dist/lib/lib.js",
18
+ "dependencies": {
19
+ "@apify/consts": "^2.43.0",
20
+ "@slack/web-api": "^7.9.2",
21
+ "apify-client": "^2.22.2",
22
+ "ignore": "^7.0.5",
23
+ "yargs": "^18.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@apify/eslint-config": "^1.0.0",
27
+ "@apify/tsconfig": "^0.1.1",
28
+ "@types/node": "^24.0.0",
29
+ "@types/yargs": "^17.0.33",
30
+ "eslint": "^9.29.0",
31
+ "eslint-config-prettier": "^10.1.5",
32
+ "globals": "^17.0.0",
33
+ "husky": "^9.0.11",
34
+ "knip": "^5.65.0",
35
+ "lint-staged": "^15.2.2",
36
+ "prettier": "^3.5.3",
37
+ "tsx": "^4.20.3",
38
+ "typescript": "^5.9.3",
39
+ "typescript-eslint": "^8.34.1",
40
+ "vitest": "^3.2.4"
41
+ },
42
+ "peerDependencies": {
43
+ "vitest": ">=3.2.4"
44
+ },
45
+ "scripts": {
46
+ "start": "npm run dist/bin/main.js",
47
+ "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
48
+ "build": "tsc && chmod +x ./dist/bin/main.js",
49
+ "lint": "eslint",
50
+ "lint:fix": "eslint --fix",
51
+ "format": "prettier --write .",
52
+ "format:check": "prettier --check .",
53
+ "type-check": "tsc --noEmit",
54
+ "test": "vitest run",
55
+ "check-unused": "npx knip",
56
+ "prepare": "husky .husky || true"
57
+ },
58
+ "lint-staged": {
59
+ "*.js": "eslint",
60
+ "*.ts": "eslint"
61
+ },
62
+ "author": "oklinov",
63
+ "license": "ISC"
64
64
  }