
Actor Testing
Pricing
Pay per usage

Actor Testing
Test your actors with varying inputs and expected outputs, duplicates, bad output fields, or unexpected log messages using Jasmine
0.0 (0)
Pricing
Pay per usage
11
Total users
32
Monthly users
3
Runs succeeded
84%
Last modified
25 days ago
You can access the Actor Testing programmatically from your own applications by using the Apify API. You can also choose the language preference from below. To use the Apify API, you’ll need an Apify account and your API token, found in Integrations settings in Apify Console.
1import { ApifyClient } from 'apify-client';2
3// Initialize the ApifyClient with your Apify API token4// Replace the '<YOUR_API_TOKEN>' with your token5const client = new ApifyClient({6 token: '<YOUR_API_TOKEN>',7});8
9// Prepare Actor input10const 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// Run the Actor and wait for it to finish61const run = await client.actor("pocesar/actor-testing").call(input);62
63// Fetch and print Actor results from the run's dataset (if any)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// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs
Actor Testing API in JavaScript
The Apify API client for JavaScript is the official library that allows you to use Actor Testing API in JavaScript or TypeScript, providing convenience functions and automatic retries on errors.
Install the apify-client
$npm install apify-client
Other API clients include: