apify-test-tools 0.7.0 → 0.7.1-beta.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
@@ -11,3 +11,8 @@ export const TO_FINISH_WITH_OPTIONS: ToFinishWithOptionsWithDefaults = {
11
11
  maxRetriesPerRequest: null,
12
12
  forbiddenLogs: ['ReferenceError', 'TypeError'],
13
13
  };
14
+
15
+ /**
16
+ * Both the test runs and the vitest test specs should finish in this time - 1 hour
17
+ */
18
+ export const DEFAULT_TEST_RUN_DURATION_MS = 60 * 60 * 1000; // 1 hour
package/lib/lib.ts CHANGED
@@ -3,6 +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
7
  import { extendExpect } from './extend-expect.js';
7
8
  import { RunTestResult } from './run-test-result.js';
8
9
  import type { ActorBuild, ActorTestOptions, RunOptions } from './types.js';
@@ -37,7 +38,7 @@ const DEFAULT_TEST_OPTIONS: ActorTestOptions = {
37
38
  // we want to run tests concurrently
38
39
  concurrent: true,
39
40
  // test should finish within 1 hour
40
- timeout: 60_000 * 60,
41
+ timeout: DEFAULT_TEST_RUN_DURATION_MS,
41
42
  };
42
43
 
43
44
  export const describe = (name: string, fn?: SuiteFactory<object>, options: ActorTestOptions = DEFAULT_TEST_OPTIONS) => {
@@ -46,6 +47,8 @@ export const describe = (name: string, fn?: SuiteFactory<object>, options: Actor
46
47
 
47
48
  const DEFAULT_TEST_ACTOR_OPTIONS: ActorTestOptions = {
48
49
  retry: 1,
50
+ // prevent orphaned runs
51
+ timeout: DEFAULT_TEST_RUN_DURATION_MS,
49
52
  };
50
53
 
51
54
  export const testActor = <T>(
@@ -124,7 +127,7 @@ export const testTestActor = <T>(
124
127
  expect: extendExpect(expect),
125
128
  // @ts-expect-error: this just to test custom matchers
126
129
  // eslint-disable-next-line @typescript-eslint/no-empty-function
127
- run: () => { },
130
+ run: () => {},
128
131
  ...rest,
129
132
  });
130
133
  });
package/lib/types.ts CHANGED
@@ -128,7 +128,7 @@ export interface ActorMatchers<R = unknown> {
128
128
  hard: <T>(actual: T, message?: string) => Assertion;
129
129
  }
130
130
 
131
- export type ActorTestOptions = Omit<TestOptions, 'retry'> & {
131
+ export type ActorTestOptions = Omit<TestOptions, 'retry' | 'timeout'> & {
132
132
  /**
133
133
  * Times to retry the test if fails. Useful for making flaky tests more stable.
134
134
  * When retries is up, the last test error will be thrown.
@@ -137,6 +137,13 @@ export type ActorTestOptions = Omit<TestOptions, 'retry'> & {
137
137
  */
138
138
  // we are just extending the docs here to replace the default value, otherwise it's the exact same
139
139
  retry?: TestOptions['retry'];
140
+ /**
141
+ * Timeout for the actor run in milliseconds. Zero value means there is no timeout.
142
+ * - If `undefined`, the run uses timeout of the default Actor run configuration.
143
+ *
144
+ * @default 60 * 60 * 1000 // 1 hour
145
+ */
146
+ timeout?: ActorCallOptions['timeout'];
140
147
  };
141
148
 
142
149
  declare module 'vitest' {
package/package.json CHANGED
@@ -1,63 +1,63 @@
1
1
  {
2
- "name": "apify-test-tools",
3
- "version": "0.7.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
- "yargs": "^18.0.0"
23
- },
24
- "devDependencies": {
25
- "@apify/eslint-config": "^1.0.0",
26
- "@apify/tsconfig": "^0.1.1",
27
- "@types/node": "^24.0.0",
28
- "@types/yargs": "^17.0.33",
29
- "eslint": "^9.29.0",
30
- "eslint-config-prettier": "^10.1.5",
31
- "globals": "^17.0.0",
32
- "prettier": "^3.5.3",
33
- "tsx": "^4.20.3",
34
- "typescript": "^5.9.3",
35
- "typescript-eslint": "^8.34.1",
36
- "vitest": "^3.2.4",
37
- "knip": "^5.65.0",
38
- "husky": "^9.0.11",
39
- "lint-staged": "^15.2.2"
40
- },
41
- "peerDependencies": {
42
- "vitest": ">=3.2.4"
43
- },
44
- "scripts": {
45
- "start": "npm run dist/bin/main.js",
46
- "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
47
- "build": "tsc && chmod +x ./dist/bin/main.js",
48
- "lint": "eslint",
49
- "lint:fix": "eslint --fix",
50
- "format": "prettier --write .",
51
- "format:check": "prettier --check .",
52
- "type-check": "tsc --noEmit",
53
- "test": "vitest run",
54
- "check-unused": "npx knip",
55
- "prepare": "husky .husky || true"
56
- },
57
- "lint-staged": {
58
- "*.js": "eslint",
59
- "*.ts": "eslint"
60
- },
61
- "author": "oklinov",
62
- "license": "ISC"
2
+ "name": "apify-test-tools",
3
+ "version": "0.7.1-beta.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
+ "yargs": "^18.0.0"
23
+ },
24
+ "devDependencies": {
25
+ "@apify/eslint-config": "^1.0.0",
26
+ "@apify/tsconfig": "^0.1.1",
27
+ "@types/node": "^24.0.0",
28
+ "@types/yargs": "^17.0.33",
29
+ "eslint": "^9.29.0",
30
+ "eslint-config-prettier": "^10.1.5",
31
+ "globals": "^17.0.0",
32
+ "prettier": "^3.5.3",
33
+ "tsx": "^4.20.3",
34
+ "typescript": "^5.9.3",
35
+ "typescript-eslint": "^8.34.1",
36
+ "vitest": "^3.2.4",
37
+ "knip": "^5.65.0",
38
+ "husky": "^9.0.11",
39
+ "lint-staged": "^15.2.2"
40
+ },
41
+ "peerDependencies": {
42
+ "vitest": ">=3.2.4"
43
+ },
44
+ "scripts": {
45
+ "start": "npm run dist/bin/main.js",
46
+ "start:dev": "GITHUB_WORKSPACE=local-clone tsx bin/main.ts",
47
+ "build": "tsc && chmod +x ./dist/bin/main.js",
48
+ "lint": "eslint",
49
+ "lint:fix": "eslint --fix",
50
+ "format": "prettier --write .",
51
+ "format:check": "prettier --check .",
52
+ "type-check": "tsc --noEmit",
53
+ "test": "vitest run",
54
+ "check-unused": "npx knip",
55
+ "prepare": "husky .husky || true"
56
+ },
57
+ "lint-staged": {
58
+ "*.js": "eslint",
59
+ "*.ts": "eslint"
60
+ },
61
+ "author": "oklinov",
62
+ "license": "ISC"
63
63
  }