1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "testSpec": ({ it, xit, moment, _, run, expect, expectAsync, input, describe }) => {
12 (input.resource ? [
13 'beta',
14 ] : [
15 'latest',
16 ]).forEach((build) => {
17 describe(`${build} version`, () => {
18 it('test something-task', async () => {
19 const runResult = await run({
20 taskId: '',
21 });
22
23 await expectAsync(runResult).toHaveStatus('SUCCEEDED');
24 await expectAsync(runResult).withLog((log) => {
25 expect(log)
26 .withContext(runResult.format('ReferenceError'))
27 .not.toContain('ReferenceError');
28 expect(log)
29 .withContext(runResult.format('TypeError'))
30 .not.toContain('TypeError');
31 });
32
33 await expectAsync(runResult).withStatistics((stats) => {
34 expect(stats.requestsRetries)
35 .withContext(runResult.format('Request retries'))
36 .toBeLessThan(3);
37
38 expect(stats.crawlerRuntimeMillis)
39 .withContext(runResult.format('Run time'))
40 .toBeWithinRange(0.1 * 60000, 10 * 60000);
41 });
42
43 await expectAsync(runResult).withDataset(({ dataset, info }) => {
44 expect(info.cleanItemCount)
45 .withContext(runResult.format('Dataset cleanItemCount'))
46 .toBeGreaterThan(0);
47
48 expect(dataset.items)
49 .withContext(runResult.format('Dataset items array'))
50 .toBeNonEmptyArray();
51 });
52 });
53 });
54 });
55 },
56 "slackChannel": "#public-actors-tests-notifications",
57 "slackPrefix": "@lead-dev @actor-owner"
58};
59
60
61const run = await client.actor("pocesar/actor-testing").call(input);
62
63
64console.log('Results from dataset');
65console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
66const { items } = await client.dataset(run.defaultDatasetId).listItems();
67items.forEach((item) => {
68 console.dir(item);
69});
70
71