Skip to content

Commit 2820877

Browse files
authored
Update Multistep check overview page (#1271)
* feat: update Multistep check overview page * feat: more small fixes for Multistep check facelift * feat: move image further down page * feat: misc changes for code review, including differentiating the check from the PW script
1 parent da3e4a9 commit 2820877

File tree

6 files changed

+112
-38
lines changed

6 files changed

+112
-38
lines changed
343 KB
Loading
260 KB
Loading
339 KB
Loading
Binary file not shown.

site/content/docs/monitoring/check-results.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,16 @@ The source shows where your ping originated, determined by the `origin` and `ref
154154

155155
Multistep check results are navigated using the tree on the left side of the screen. If you are running checks in parallel, first select the location you are interested in.
156156

157-
In the result tree the top node shows the check run log and the check run configuration. Both can be collapsed.
157+
In the result tree, the top node shows the check run log and the check run configuration.
158158

159159
Any errors encountered can be viewed in the 'Errors' node.
160160

161-
Each Playwright request done is shown as a separate node under the test step in which it was performed. Selecting a request node opens the request details. Here you can view the request and response body, headers and any request parameters. A breakdown of the request timings is also available.
161+
Each Playwright request is shown as a separate node under the test step in which it was performed. Selecting a request node opens the request details. Here you can view the request and response body, headers and any request parameters. A breakdown of the request timings is also available. If you've made assertions in the same test step as this request, then those assertions will be shown here.
162162

163-
Currently, only requests done using the Playwright `request` are shown as nodes in the tree, requests done via e.g Axios or HTTPS are not.
163+
The default request user-agent is `Checkly/1.0 (https://www.checklyhq.com)`.
164+
If you would like to use a different user-agent, you can add `test.use({userAgent: 'customUserAgent'})` to your script.
164165

165-
In the request details you will also find the result of any assertion done as part of the corresponding test step.
166+
Currently, only requests done using the Playwright `request` are shown as nodes in the tree, requests done via e.g Axios or HTTPS are not.
166167

167168
![Using the Multistep check results view](/docs/images/monitoring/check-results-multistep.mp4)
168169

site/content/docs/multistep-checks/_index.md

Lines changed: 107 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ aliases:
1414

1515
---
1616

17+
Make multiple API calls in sequence with Multistep checks. Monitor complete API flows — like logging in, adding to cart, and checking out — to verify your combined API interactions work as expected.
18+
1719
This guide gives you all the info to create your first Multistep check with Checkly. You should have some prior
18-
knowledge of working with JavaScript and/or Node.js.
20+
knowledge of working with JavaScript/TypeScript and/or Node.js.
1921

2022
## What is a Multistep check?
2123

22-
Multistep checks enable you to write Node.js scripts that can run multiple API requests in sequence. They allow you to monitor entire API user flows with a single check. Make requests, parse response data and perform more requests to mimic and test API user behavior. Multistep checks ensure that combined API interactions lead to the correct results.
24+
Multistep checks enable you to write Node.js Playwright scripts that can run multiple API requests in sequence. They allow you to monitor entire API user flows with a single check. Make requests, parse response data and perform more requests to mimic and test API user behavior. Multistep checks ensure that combined API interactions lead to the correct results.
2325

2426
Examples of API sequences might be:
2527

@@ -29,13 +31,15 @@ Examples of API sequences might be:
2931

3032
Monitoring your API user flows instead of individual endpoints gives confidence that your product as a whole works as intended and that the expected interactions between API calls are functional.
3133

34+
![Multistep check overview page](/docs/images/multistep-api-checks/multistep-check-overview.png)
35+
3236
Multistep checks are powered by `@playwright/test`'s [API Testing](https://playwright.dev/docs/api-testing) mode. Meaning you get all of the power of our typical API checks in the form of a programmable `@playwright/test` check.
3337

3438
> Multistep checks are only supported on runtime 2023.09 or later. See [Runtimes](/docs/runtimes/) for more details.
3539
36-
The following code is a valid Multistep check using Playwright Test. It creates and deletes an API resource in a single run.
40+
For example, here is a valid Playwright API test script that we can use in a Multistep check. It creates and deletes an API resource in a single run.
3741

38-
```ts {title="multistep.spec.ts"}
42+
```ts {title="example.spec.ts"}
3943
import { test, expect } from '@playwright/test' // 1
4044
4145
const headers = { // 2
@@ -67,47 +71,57 @@ test('create and delete a check group', async ({ request }) => { // 3
6771
})
6872
```
6973

70-
## Breaking down a Multistep check
74+
## Breaking down a Playwright API test
7175

72-
Let's look at the code above step by step.
76+
Let's look at the code above step-by-step, as it determines what our Multistep check will do.
7377

74-
**1. Initial declarations:** To run any Multistep check, import the Playwright test framework.
78+
**1. Initial declarations:** Import the Playwright test framework.
7579

76-
**2. Define our headers:** In many cases you will have to authenticate when requesting data by providing authorization headers. Use [environment variables](/docs/browser-checks/variables/) to avoid having any confidential data in our test.
80+
**2. Define our headers:** In many cases, you will have to authenticate when requesting data by providing authorization headers. Use [environment variables](/docs/browser-checks/variables/) to avoid having any confidential data in your test.
7781

7882
**3. Establish environment:** Create a new test and leverage the Playwright `request` fixture to make API requests in the test steps.
7983

80-
**4. Declare our first `test.step`:** The test step uses the `request` to perform a `get` request, using the headers we defined earlier.
84+
**4. Declare our first `test.step`:** The test step uses the `request` to perform a `post` request, using the headers we defined earlier.
8185

8286
>[!NOTE]
8387
> Always use `await` before `test.step`, otherwise the test will fail.
8488
85-
**5. Define our assertion:** Use the `expect(response)` method to assert if the response was successful (The response code is in the range of 200 - 299) with `toBeOK()`. Should the request return anything outside of the 'OK' range, this will cause the check to fail and in a production scenario trigger any configured alerts.
89+
**5. Define our assertion:** Use the `expect(response)` method to assert if the response was successful (the response code is in the range of 200 - 299) with `toBeOK()`. Should the request return anything outside of the 'OK' range, the check will fail and in a production scenario, trigger any configured alerts.
8690

8791
**6. Return the response for future usage:** Return the request response in JSON format, so we can use it in the next test step.
8892

8993
**7. Declare our second `test.step`:** In order to remove the test group we just created, and avoid cluttering our system with test data, remove it by sending a `delete` request using the group ID that was returned in our earlier test step. Use the same `toBeOK()` assertion as in the previous test step.
9094

91-
If you want to build on the above example, you can add additional assertions, ensuring that the data returned is correct and contains a specific check, or add a `PUT` and `GET` test step to verify more of the `/groups` functionality.
95+
If you want to build on the above example, you can add additional assertions, ensuring that the data returned is correct and contains a specific check, or add a `PUT` and `GET` test step to verify more of the `/check-groups` functionality.
9296

9397
## Creating a Multistep check
9498

99+
![Multistep check edit page](/docs/images/multistep-api-checks/create-multistep-check.png)
100+
101+
### Name and tags
102+
103+
A meaningful name will not only help you and others identify your checks within Checkly, but it will help provide a better alerting experience if your checks fall into an alert state.
104+
105+
Tags can relate your checks together. They also determine which checks are shown on your [dashboards](/docs/dashboards/).
106+
107+
### Playwright script
108+
95109
A valid Multistep check is based on a valid [Playwright API test script](https://playwright.dev/docs/api-testing). You can create these scripts either in the in-app editor, or write them in your IDE and deploy them using the [Checkly CLI](/docs/cli/). For production, we recommend using the CLI so you can leverage best practices such as version control and code reviews before updating your checks.
96110

97111
> Valid Playwright Test API scripts are the foundation of a valid Multistep check. If the script passes, your check passes.
98112
> If the script fails, your check fails.
99113
100-
### Structuring a Multistep check
114+
#### Structuring a Multistep check
101115

102-
To preserve test isolation and provide a structured report view of Multistep checks, Checkly relies on Playwright's [test.step](https://playwright.dev/docs/api/class-test#test-step) method. Your Multistep test can have several test steps.
116+
To preserve test isolation and provide a structured report view of Multistep checks, Checkly relies on Playwright's [test.step](https://playwright.dev/docs/api/class-test#test-step) method. Your Multistep check can have several test steps.
103117

104-
**API requests and assertions in the same test step will be presented under the same node in the reporting structure.**
118+
API requests and assertions in the same test step will be presented under the same node in the reporting structure.
105119

106120
![Multistep test results](/docs/images/multistep-api-checks/test-results.jpg)
107121

108-
To provide actionable and easy to read check run reports we recommend using the `test.step()` structure when writing Multistep checks.
122+
To provide actionable and easy-to-read [check run results](/docs/monitoring/check-results/#multistep-check-results), we recommend using the `test.step()` structure when writing the Playwright script for you Multistep check.
109123

110-
```ts {title="multisteps.spec.ts"}
124+
```ts {title="my-test.spec.ts"}
111125
import { test, expect } from '@playwright/test'
112126

113127
const baseUrl = 'https://api.checklyhq.com/v1'
@@ -126,44 +140,103 @@ test('My test', async ({request}) => {
126140
})
127141
```
128142

129-
### Building checks in the web editor
143+
#### Building scripts in the web editor
144+
145+
You can edit and debug Playwright scripts straight from the web editor. Use the "Run Script" button to run your script ad-hoc, without recording it as a scheduled run.
146+
147+
![Multistep check editor](/docs/images/multistep-api-checks/multistep-check-editor.png)
148+
149+
In the sidebar, you can view:
150+
151+
- File dependencies
152+
- Your Playwright config file (if your check was created with the [Checkly CLI](/docs/cli/))
153+
- The test report
154+
- OpenTelemetry traces for this run (if you've enabled [Checkly Traces](/docs/traces-open-telemetry/))
155+
- [Runtimes](/docs/runtimes/), including the packages in your current runtime
156+
157+
After each test run, you can view the result tree by selecting the test report in the editor sidebar. Selecting an API request shows details about that request. You can also view errors and any failed assertions in this report.
130158

131-
When creating a check using the web editor, after each test run you can open up the result tree by clicking on the 'Test report' icon on the left side of the editor. Selecting an API response opens the response details. You can also view errors and any failed assertion in the report view.
159+
### Scheduling & locations
132160

133-
![API test step assertion](/docs/images/multistep-api-checks/test-step-assertion.jpg)
161+
You can configure your checks to run from our [public](/docs/monitoring/global-locations/) locations, or use a Checkly Agent to host your own [private](/docs/private-locations/) locations. If you don't select more than one location and you've disabled retrying checks from the same location, we will pick a random location when retrying checks.
134162

135-
## Multistep result view
163+
Checkly runs your Multistep checks based on an interval you set. The shortest interval you can run is every minute and the longest is every 24 hours.
136164

137-
When viewing a Multistep check run result, you can select any API request in the result tree to view the full response details. If you have your API request and related assertions in the same `test.step`, related requests and failing assertions will be grouped under the same header.
165+
### Retries & alerting
138166

139-
The default request user-agent is `Checkly/1.0 (https://www.checklyhq.com)`.
140-
If you would like to use a different user-agent, you can do so with `test.use({userAgent: 'customerUserAgent'})`.
167+
Select your preferred [retry strategy](/docs/alerting-and-retries/retries/) for failed checks.
141168

142-
Selecting the top node in the check report shows the full job log and the check configuration for the run.
169+
Choose which [alert channels](/docs/alerting-and-retries/alert-channels/) to get notified through when your check runs into issues. If we don't have your preferred alert method, use [webhooks](/docs/alerting-and-retries/webhooks/) to configure your alert flow.
170+
171+
### Testing
172+
173+
You can run your check as an [E2E test](/docs/testing) locally or from your CI/CD pipeline to validate your freshly deployed application. Use the Checkly CLI, or configure integrations with Vercel and GitHub.
143174

144175
## Built-in runtime variables
145176

146-
[The Multistep Check runtime](/docs/runtimes/) also exposes a set of environment variables (e.g. `process.env.CHECK_NAME`)
147-
to figure out what check, check type etc. you are running.
177+
The Multistep check [runtime](/docs/runtimes/) exposes a set of environment variables (e.g. `process.env.CHECK_NAME`) that indicate what check, check type etc. you are running.
148178

149179
{{< markdownpartial "/_shared/runtime-env-vars.md" >}}
150180

151181
## Timeouts
152-
As with Browser checks, Checkly runs a Multistep Check for a maximum of 240s. Scripts exceeding this will timeout. For more information on how to work with the timeout limits for Multistep and Browser checks, see [Timeouts](/docs/browser-checks/timeouts).
182+
As with Browser checks, Checkly runs Multistep checks for a maximum of 240s. Scripts exceeding this will timeout. For more information on how to work with the timeout limits for Multistep and Browser checks, see [Timeouts](/docs/browser-checks/timeouts).
183+
184+
## CLI example
185+
186+
The [Checkly CLI](/docs/cli/) gives you a JavaScript/TypeScript-native workflow for coding, testing and deploying synthetic monitoring at scale, from your code base.
187+
188+
You can define a Multistep check via the CLI. Unlike Browser checks, Multistep checks always need to be defined in a construct. For example:
189+
190+
{{< tabs "CLI example" >}}
191+
{{< tab "TypeScript" >}}
192+
```ts {title="multistep.check.ts"}
193+
import { MultiStepCheck, Frequency } from 'checkly/constructs'
194+
import * as path from 'path'
153195

196+
new MultiStepCheck('multistep-check-1', {
197+
name: 'Multistep Check #1',
198+
frequency: Frequency.EVERY_10M,
199+
locations: ['us-east-1', 'eu-west-1'],
200+
code: {
201+
entrypoint: path.join(__dirname, 'example.spec.ts')
202+
},
203+
})
204+
```
205+
{{< /tab >}}
206+
{{< tab "JavaScript" >}}
207+
```js {title="multistep.check.js"}
208+
const { MultiStepCheck, Frequency } = require('checkly/constructs')
209+
const path = require('path')
210+
211+
new MultiStepCheck('multistep-check-1', {
212+
name: 'Multistep Check #1',
213+
frequency: Frequency.EVERY_10M,
214+
locations: ['us-east-1', 'eu-west-1'],
215+
code: {
216+
entrypoint: path.join(__dirname, 'example.spec.ts')
217+
},
218+
})
219+
```
220+
{{< /tab >}}
221+
{{< /tabs >}}
154222

155-
## Pricing
223+
The above example defines:
224+
- The basic check properties like `name`, `frequency` etc.
225+
- The path to the target Playwright test file, `example.spec.ts`.
156226

157-
A Multistep check is billed based on the number of requests done per check run. Each request in a Multistep check run is billed as a single regular API check run, as they are performing the same basic operation.
227+
For more options, see the [Check construct reference](/docs/cli/constructs-reference/#check).
158228

159-
As an example, let's say you have 4 API checks, where each check doing one of the `GET`, `POST`, `PUT` and `DELETE` operations towards the same endpoint. If you replace these 4 checks with a single Multistep check that runs 4 requests towards the same endpoint, checking each method, and the check run frequency is the same as before, your cost stays the same
229+
## Next steps
160230

161-
A Multistep check with 0 requests is billed as if it has 1 request.
231+
- Learn about the benefits of [Monitoring as Code](/guides/monitoring-as-code/).
232+
- See [example scripts](/docs/multistep-checks/example-checks/) for authentication, CRUD testing, and more.
233+
- Understand [pricing and billing](/docs/monitoring/check-pricing/#multistep-checks) for Multistep checks.
234+
- Learn more about [resource limitations](/docs/runtimes/specs/#resource-limitations) for Multistep checks.
162235

163-
## Resources
236+
## More Playwright resources
164237

238+
- [Learn Playwright](/learn/playwright/), Checkly's free and open source Playwright knowledge base.
165239
- [Checkly's YouTube channel](https://www.youtube.com/@ChecklyHQ) where we regularly publish tutorials and tips.
166240
- [playwright.dev](https://playwright.dev/) is the official API documentation site for the Playwright framework.
167241
- [awesome-playwright](https://github.com/mxschmitt/awesome-playwright) is a great GitHub repo full of
168-
Playwright-related libraries, tips and resources.
169-
- Learn more about [resource limitations](/docs/runtimes/specs/#resource-limitations) for Multistep checks.
242+
Playwright-related libraries, tips and resources.

0 commit comments

Comments
 (0)