apify-test-tools 0.2.0 → 0.2.2
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/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 +11 -1
- package/dist/lib/run-test-result.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lib/run-test-result.ts +13 -2
- package/package.json +1 -1
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,13 +43,23 @@ 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
|
|
48
58
|
}
|
|
49
59
|
const kvs = this.apifyClient.keyValueStore(this.run.defaultKeyValueStoreId);
|
|
50
60
|
const input = await kvs.getRecord('INPUT');
|
|
51
|
-
|
|
61
|
+
this.input = input?.value;
|
|
62
|
+
return this.input as T;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
getRunInfo = async (): Promise<ActorRun> => {
|