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