apify-test-tools 0.2.1 → 0.2.3
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/CHANGELOG.md +16 -0
- package/bin/build.ts +13 -10
- package/dist/bin/build.d.ts.map +1 -1
- package/dist/bin/build.js +13 -6
- package/dist/bin/build.js.map +1 -1
- package/dist/lib/extend-expect.js +1 -1
- package/dist/lib/extend-expect.js.map +1 -1
- package/dist/lib/lib.d.ts.map +1 -1
- package/dist/lib/lib.js +8 -1
- package/dist/lib/lib.js.map +1 -1
- package/dist/lib/run-test-result.d.ts +3 -1
- package/dist/lib/run-test-result.d.ts.map +1 -1
- package/dist/lib/run-test-result.js +9 -0
- package/dist/lib/run-test-result.js.map +1 -1
- package/dist/lib/types.d.ts +7 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/extend-expect.ts +1 -1
- package/lib/lib.ts +10 -0
- package/lib/run-test-result.ts +11 -1
- package/lib/types.ts +7 -0
- package/package.json +1 -1
package/lib/extend-expect.ts
CHANGED
|
@@ -175,7 +175,7 @@ export const extendExpect = (expect: ExpectStatic): ExpectStatic => {
|
|
|
175
175
|
isWithinInterval(ppeDiffs, actual[ppeEvent], expected, ppeEvent as PpeEvent);
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
diffs.pass = ppeDiffs.pass;
|
|
178
|
+
diffs.pass = diffs.pass && ppeDiffs.pass;
|
|
179
179
|
diffs.actual.push(ppeDiffs.actual.join('\n '));
|
|
180
180
|
diffs.expected.push(ppeDiffs.expected.join('\n '));
|
|
181
181
|
}
|
package/lib/lib.ts
CHANGED
|
@@ -234,7 +234,17 @@ const createStartRunFn = <T>(actorNameOrId: string, testContext: TestContext) =>
|
|
|
234
234
|
input,
|
|
235
235
|
options,
|
|
236
236
|
prefilledInput,
|
|
237
|
+
runId,
|
|
237
238
|
} = runOptions;
|
|
239
|
+
|
|
240
|
+
if (runId) {
|
|
241
|
+
const run = await apifyClient.run(runId).get()
|
|
242
|
+
if (!run) {
|
|
243
|
+
throw new Error(`Run with id "${runId}" doesn't exist`);
|
|
244
|
+
}
|
|
245
|
+
return new RunTestResult(apifyClient, run)
|
|
246
|
+
}
|
|
247
|
+
|
|
238
248
|
const actor = apifyClient.actor(actorNameOrId);
|
|
239
249
|
|
|
240
250
|
const actorInput = {
|
package/lib/run-test-result.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ActorRun, ApifyClient } from 'apify-client';
|
|
1
|
+
import { ActorRun, ApifyClient, KeyValueStoreClient } from 'apify-client';
|
|
2
2
|
import type { Dataset, SdkCrawlerStatistics } from './types';
|
|
3
3
|
|
|
4
4
|
export class RunTestResult {
|
|
5
5
|
private log: string | undefined;
|
|
6
6
|
private dataset: Dataset<unknown> | undefined;
|
|
7
|
+
private keyValueStoreClient: KeyValueStoreClient | undefined;
|
|
7
8
|
private statistics: SdkCrawlerStatistics | undefined;
|
|
8
9
|
private runInfo: ActorRun | undefined;
|
|
9
10
|
private input: unknown | undefined;
|
|
@@ -42,6 +43,15 @@ export class RunTestResult {
|
|
|
42
43
|
return this.dataset as Dataset<T>;
|
|
43
44
|
};
|
|
44
45
|
|
|
46
|
+
getKeyValueStoreClient = (): KeyValueStoreClient => {
|
|
47
|
+
if (this.keyValueStoreClient) {
|
|
48
|
+
return this.keyValueStoreClient;
|
|
49
|
+
}
|
|
50
|
+
const keyValueStoreClient = this.apifyClient.keyValueStore(this.run.defaultKeyValueStoreId);
|
|
51
|
+
this.keyValueStoreClient = keyValueStoreClient;
|
|
52
|
+
return keyValueStoreClient
|
|
53
|
+
};
|
|
54
|
+
|
|
45
55
|
getInput = async<T>(): Promise<T> => {
|
|
46
56
|
if (this.input) {
|
|
47
57
|
return this.input as T
|
package/lib/types.ts
CHANGED
|
@@ -12,6 +12,13 @@ export type RunOptions<T> = {
|
|
|
12
12
|
input: Omit<T, 'actorName'>
|
|
13
13
|
options?: ActorCallOptions
|
|
14
14
|
prefilledInput?: boolean
|
|
15
|
+
/**
|
|
16
|
+
* If you specify `runId`, all the other options will be ignored and this run's data will
|
|
17
|
+
* be downloaded instead.
|
|
18
|
+
*
|
|
19
|
+
* This is usefull for testing your tests on existing runs
|
|
20
|
+
*/
|
|
21
|
+
runId?: string
|
|
15
22
|
}
|
|
16
23
|
|
|
17
24
|
export type Dataset<T> = {
|