Actor Testing avatar
Actor Testing
Try for free

No credit card required

View all Actors
Actor Testing

Actor Testing

pocesar/actor-testing
Try for free

No credit card required

Test your actors with varying inputs and expected outputs, duplicates, bad output fields, or unexpected log messages using Jasmine

The code examples below show how to run the Actor and get its results. To run the code, you need to have an Apify account. Replace <YOUR_API_TOKEN> in the code with your API token, which you can find under Settings > Integrations in Apify Console. Learn more

1# Set API token
2API_TOKEN=<YOUR_API_TOKEN>
3
4# Prepare Actor input
5cat > input.json <<'EOF'
6{
7  "testSpec": "({ it, xit, moment, _, run, expect, expectAsync, input, describe }) => {\n    (input.resource ? [\n        'beta',\n    ] : [\n        'latest',\n    ]).forEach((build) => {\n        describe(`${build} version`, () => {\n            it('test something-task', async () => {\n                const runResult = await run({\n                    taskId: '',\n                });\n\n                await expectAsync(runResult).toHaveStatus('SUCCEEDED');\n                await expectAsync(runResult).withLog((log) => {\n                    expect(log)\n                        .withContext(runResult.format('ReferenceError'))\n                        .not.toContain('ReferenceError');\n                    expect(log)\n                        .withContext(runResult.format('TypeError'))\n                        .not.toContain('TypeError');\n                });\n\n                await expectAsync(runResult).withStatistics((stats) => {\n                    expect(stats.requestsRetries)\n                        .withContext(runResult.format('Request retries'))\n                        .toBeLessThan(3);\n\n                    expect(stats.crawlerRuntimeMillis)\n                        .withContext(runResult.format('Run time'))\n                        .toBeWithinRange(0.1 * 60000, 10 * 60000);\n                });\n\n                await expectAsync(runResult).withDataset(({ dataset, info }) => {\n                    expect(info.cleanItemCount)\n                        .withContext(runResult.format('Dataset cleanItemCount'))\n                        .toBeGreaterThan(0);\n\n                    expect(dataset.items)\n                        .withContext(runResult.format('Dataset items array'))\n                        .toBeNonEmptyArray();\n                });\n            });\n        });\n    });\n}",
8  "slackChannel": "#public-actors-tests-notifications",
9  "slackPrefix": "@lead-dev @actor-owner"
10}
11EOF
12
13# Run the Actor using an HTTP API
14# See the full API reference at https://docs.apify.com/api/v2
15curl "https://api.apify.com/v2/acts/pocesar~actor-testing/runs?token=$API_TOKEN" \
16  -X POST \
17  -d @input.json \
18  -H 'Content-Type: application/json'
Developer
Maintained by Community
Actor metrics
  • 2 monthly users
  • 9 stars
  • 80.1% runs succeeded
  • Created in Dec 2020
  • Modified 10 days ago
Categories