You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/guides/run-on-preview-deployment.mdx
+98-51Lines changed: 98 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,53 +5,118 @@ title: Run on Preview Deployments
5
5
6
6
# Run on Preview Deployments
7
7
8
-
Seamlessly test preview deployments with Argos: Automate visual testing on platforms like Vercel, Cloudflare, and Netlify via GitHub Actions.
8
+
Catch visual regressions **before merging** by running automated tests on every preview deployment.
9
9
10
-
## Configure a GitHub Action
10
+
Argos integrates with GitHub Actions and connects seamlessly with providers like **Vercel, Netlify, and Cloudflare**.
11
11
12
-
For Argos to work with your deployment previews, your deployment service must be integrated with GitHub to create deployments. This setup allows Argos to trigger tests on successful deployment previews.
12
+
With this setup:
13
13
14
-
### GitHub Workflow Configuration
14
+
- Each deployment preview is tested automatically
15
+
- Regressions are surfaced directly in your pull requests
16
+
- Your production baseline stays reliable and up to date
15
17
16
-
Here's how to configure a GitHub Action to trigger tests with Argos on deployment previews. Create a workflow file in `.github/workflows` directory like so:
18
+
## Setup with Vercel repository dispatch events
17
19
18
-
```yml
20
+
Vercel can notify GitHub on every deployment via a [`repository_dispatch` event](https://vercel.com/docs/git/vercel-for-github#repository-dispatch-events).
21
+
22
+
Argos can use this payload to run visual tests against the preview URL.
23
+
24
+
```yaml title=".github/workflows/ci.yml"
25
+
name: Playwright + Argos Tests
26
+
27
+
on:
28
+
repository_dispatch:
29
+
types:
30
+
- "vercel.deployment.success"
31
+
32
+
permissions:
33
+
contents: read
34
+
# Required to access pull request metadata for Argos with GITHUB_TOKEN
# Provided by GitHub used by Argos to link builds to branches and pull requests
58
+
# Optional, if not provided Argos will not link builds to PRs
59
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60
+
```
61
+
62
+
## Setup with GitHub deployment status events
63
+
64
+
If your hosting provider emits GitHub Deployments events Vercel, Netlify, Cloudflare, you can trigger tests from the [`deployment_status` event](https://docs.github.com/en/webhooks/webhook-events-and-payloads#deployment_status).
65
+
66
+
The event carries the preview URL when a deployment becomes successful.
67
+
68
+
```yaml title=".github/workflows/ci.yml"
19
69
name: Playwright + Argos Tests
20
70
21
71
on:
22
72
deployment_status:
73
+
74
+
permissions:
75
+
contents: read
76
+
# Required to access pull request metadata for Argos with GITHUB_TOKEN
- `BASE_URL`: Set to your deployment URL, for running E2E tests on the actual preview.
47
-
- `GITHUB_TOKEN`: Used by Argos for accessing branch and PR info. [Provided by default by GitHub](https://docs.github.com/en/actions/security-guides/automatic-token-authentication).
48
-
- `ARGOS_BRANCH`: Needed when deploying to "Production". Argos requires you to manually specify the branch in this case.
113
+
By default, Vercel may inject a toolbar overlay into preview deployments. This can interfere with automated screenshots.
49
114
50
-
### Disable Vercel Toolbar
115
+
To avoid false diffs, disable the toolbar in your tests by sending the [`x-vercel-skip-toolbar` header](https://vercel.com/docs/vercel-toolbar/managing-toolbar#disable-toolbar-for-automation) with every request.
51
116
52
-
The Vercel Toolbar might appear in your screenshots. Here's [how to disable it](https://vercel.com/docs/workflow-collaboration/vercel-toolbar#disable-toolbar-for-session) for cleaner test visuals:
117
+
### Playwright
53
118
54
-
**For Playwright:**
119
+
Add the header in your `playwright.config.ts` so all test requests skip the toolbar:
If you prefer not to use `GITHUB_TOKEN` due to security concerns, be aware of the following limitations:
145
+
## Running without GITHUB_TOKEN
81
146
82
-
- Deployments will be linked to the branch name rather than specific PR info.
83
-
- No direct PR link will be available in Argos.
147
+
You can run Argos tests without exposing `GITHUB_TOKEN`. This is useful if you want to limit token scope in deployment workflows.
84
148
85
-
To mitigate these limitations, it's important to designate your main production environment (e.g., "Production" in Vercel) as the "reference branch" in your project's Argos settings.
149
+
However, some features will not be available:
86
150
87
-

151
+
- Builds are only associated with a branch (no pull request metadata).
Argos SDKs warn if `GITHUB_TOKEN` is missing. To silence this, set
157
+
`DISABLE_GITHUB_TOKEN_WARNING=true`.
111
158
112
-
Argos SDKs show a warning when a `GITHUB_TOKEN` is not set. You can suppress this warning by setting the `DISABLE_GITHUB_TOKEN_WARNING` environment variable to true.
0 commit comments