Skip to content

Commit f879ac6

Browse files
authored
docs: rewrite automated tests (#1163)
streamline prose add code tabs to tests scenarios move doc out of deployment section into development section
1 parent 2b1e1ee commit f879ac6

File tree

3 files changed

+40
-26
lines changed

3 files changed

+40
-26
lines changed

sources/platform/actors/development/deployment/automated_tests.md renamed to sources/platform/actors/development/automated_tests.md

Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,55 @@
11
---
22
title: Automated tests
33
description: Learn how to automate ongoing testing and make sure your Actors perform over time. See code examples for configuring the Actor Testing Actor.
4-
slug: /actors/development/deployment/automated-tests
5-
sidebar_position: 3
4+
slug: /actors/development/automated-tests
5+
sidebar_position: 9
66
---
77

88
**Learn how to automate ongoing testing and make sure your Actors perform over time. See code examples for configuring the Actor Testing Actor.**
99

10+
import Tabs from '@theme/Tabs';
11+
import TabItem from '@theme/TabItem';
12+
1013
---
1114

12-
You should make sure your [Actors](../../index.mdx) are well-maintained. You might not always get feedback from your users. Therefore, it is crucial that you periodically check if your Actors work as expected. You can do this using our [monitoring suite](https://apify.com/apify/monitoring) or by setting up daily runs of the **Actor Testing** ([pocesar/actor-testing](https://apify.com/pocesar/actor-testing)) tool.
15+
# Automated tests for Actors
1316

14-
The monitoring suite is sufficient for most scenarios and includes automated alerts. [See more information](https://apify.com/apify/monitoring) on the suite's page or [check out our tutorials](../../../monitoring/index.md).
17+
Automated testing is crucial for maintaining the reliability and performance of your Actors over time. This guide will help you set up automated tests using the [Actor Testing Actor](https://apify.com/pocesar/actor-testing).
1518

16-
We recommend using the Actor Testing Actor for specific and advanced use cases. This guide will help you set it up.
19+
## Set up automated tests
1720

18-
## Step-by-step guide
21+
1. Prepare test tasks - Create 1–5 separate testing tasks for your Actor.
22+
1. Configure Actor testing - Set up a task using the Actor Testing Actor.
23+
1. Validate tests - Run the test task multiple times until all tests pass.
24+
1. Schedule tests - Set up a recurring schedule for your tests.
25+
1. Monitor results - Review and address any issues on a weekly basis.
1926

20-
1. Prepare 1–5 separate testing tasks for your Actor. ([See below](#set-up-tasks-you-will-test)).
21-
2. Set up a task from the Actor Testing Actor. ([See below](#set-up-a-task-from-the-actor-testing-actor)).
22-
3. Run the test task until all tests succeed (a few times).
23-
4. Schedule the test to run at the frequency of your choice (recommended daily) and choose a communication channel receiving info about it ([Slack](https://apify.com/katerinahronik/slack-message) or [email](https://apify.com/apify/send-mail)).
24-
5. Ensure you review and fix any issues on a weekly basis.
27+
## Create test tasks
2528

26-
## Set up tasks you will test
29+
Example of Actor testing tasks
2730

28-
![Tasks that test an Actor's configurations](./images/testing-tasks.png)
31+
When creating test tasks:
2932

30-
We also advise you to test your Actor's default run—one that uses the pre-filled inputs. It is often the first task your users run, and they may be put off if it doesn't work.
33+
* Include a test for your Actor's default configuration
34+
* Set a low `maxItem` value to conserve credits
35+
* For large data tests, reduce test frequency to conserve credits
3136

32-
Set a low `maxItem` value for your testing tasks, so that you don't burn your credit. If you need to test your Actor with a large amount of data, set the scheduler to run less frequently.
37+
## Configure the Actor Testing Actor
3338

34-
## Set up a task from the Actor Testing Actor
39+
Follow the [setup guide](https://apify.com/pocesar/actor-testing) in the Actor's README.
3540

36-
You can [find the setup guide](https://apify.com/pocesar/actor-testing) in the Actor's README. We recommend testing for the following scenarios.
41+
Here are some recommended test scenarios:
3742

38-
Run status:
43+
<Tabs groupId="main">
44+
<TabItem value="Run status" label="Run status">
3945

4046
```js
4147
await expectAsync(runResult).toHaveStatus('SUCCEEDED');
4248
```
4349

44-
Crash information from the log:
50+
</TabItem>
51+
<TabItem value="Crash information from the log" label="Crash information from the log">
52+
4553

4654
```js
4755
await expectAsync(runResult).withLog((log) => {
@@ -58,7 +66,8 @@ await expectAsync(runResult).withLog((log) => {
5866
});
5967
```
6068

61-
Information from statistics (runtime, retries):
69+
</TabItem>
70+
<TabItem value="Information from statistics (runtime, retries)" label="Information from statistics (runtime, retries)">
6271

6372
```js
6473
await expectAsync(runResult).withStatistics((stats) => {
@@ -74,7 +83,8 @@ await expectAsync(runResult).withStatistics((stats) => {
7483
});
7584
```
7685

77-
Information about and from within the [dataset](../../../storage/dataset.md):
86+
</TabItem>
87+
<TabItem value="Information about and from within the dataset" label="Information about and from within the dataset">
7888

7989
```js
8090
await expectAsync(runResult).withDataset(({ dataset, info }) => {
@@ -103,7 +113,8 @@ await expectAsync(runResult).withDataset(({ dataset, info }) => {
103113
});
104114
```
105115

106-
Information about the [key-value store](../../../storage/key_value_store.md):
116+
</TabItem>
117+
<TabItem value="Information about the key-value store" label="Information about the key-value store">
107118

108119
```js
109120
await expectAsync(runResult).withKeyValueStore(({ contentType }) => {
@@ -117,3 +128,6 @@ await expectAsync(runResult).withKeyValueStore(({ contentType }) => {
117128
{ keyName: 'apify.com-scroll_losless-comp' },
118129
);
119130
```
131+
132+
</TabItem>
133+
</Tabs>

sources/platform/actors/publishing/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ To build a public Actor, you'll go through the following four main stages:
1515

1616
1. [Development](../development/index.md).
1717
2. [Publication](./publishing/publish) and set up of [monetization](./publishing/monetize).
18-
3. [Testing](../development/deployment/automated_tests.md).
18+
3. [Testing](../development/automated_tests.md).
1919
4. [Promotion](../../academy/get-most-of-actors/seo-and-promotion).
2020

2121
While you don't necessarily have to maintain your private Actors, public Actors require a higher degree of responsibility.
2222

2323
As the name implies, Public Actors are available to the public on [Apify Store](https://apify.com/store), which means that an unmaintained public Actor could negatively affect all the other users that depend on it for their own activities on the platform.
2424

25-
Public Actors are regularly submitted to [automated tests](./testing.mdx) to ensure they are functioning properly. Before making an Actor public, we recommend you reserve enough time to maintain the project (~2 hours weekly). This will ensure that your Actor maintains its long-term quality, improving your chances of successfully [monetizing your Actors](./monetize.mdx).
25+
Public Actors are regularly submitted to [automated tests](/platform/actors/publishing/test) to ensure they are functioning properly. Before making an Actor public, we recommend you reserve enough time to maintain the project (~2 hours weekly). This will ensure that your Actor maintains its long-term quality, improving your chances of successfully [monetizing your Actors](./monetize.mdx).
2626

2727
<img src={require("./images/apify-store.png").default} title="Apify Store" width="60%" />
2828

@@ -34,7 +34,7 @@ If you plan on making a breaking change, please get in touch with us ahead of ti
3434

3535
Also, pay special attention to your Actor's documentation ([README](../../academy/get-most-of-actors/actor-readme)). It should be clear, detailed, and readable. Think of the users, who might not be developers, so try to use simple, easy-to-understand language and avoid technical jargon.
3636

37-
Ensure periodic testing. You can either do it yourself or [set up automatic testing](../development/deployment/automated_tests.md) / [monitoring](https://apify.com/apify/monitoring). Try to prevent your users from coming to you with the issues.
37+
Ensure periodic testing. You can either do it yourself or [set up automatic testing](../development/automated_tests.md) / [monitoring](https://apify.com/apify/monitoring). Try to prevent your users from coming to you with the issues.
3838

3939
## Inspiration
4040

sources/platform/actors/publishing/testing.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ If that's the case with your Actor, please contact support at [[email protected]
3939

4040
You can easily implement your own tests and customize them to fit your Actor's particularities
4141
by using our public [Actor Testing](https://apify.com/pocesar/actor-testing) tool available in Apify Store.
42-
For more information, see the [automated testing](../development/deployment/automated_tests.md) section.
42+
For more information, see the [automated testing](../development/automated_tests.md) section.

0 commit comments

Comments
 (0)