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
title: How to run Argos visual testing on Vercel Preview
3
-
description: Guide to run Argos visual testing on Vercel Preview to ensure consistency in production-like environment.
4
-
slug: vercel-preview
2
+
title: "Guide: Integrating Argos Visual Testing in Vercel Preview"
3
+
description: "A guide to setting up Argos integration with Vercel Preview using GitHub Actions."
5
4
category: Developer Experience
6
5
author: Jeremy Sfez
7
6
date: 2024-02-01
8
7
image: ./main.jpg
9
8
imageAlt: Vercel covered with Argos
10
9
---
11
10
12
-
Great news for Vercel enthusiasts! Argos seamlessly integrates visual testing with Vercel Preview, enabling you to detect visual regressions in a production-like environment effortlessly. This guide walks you through setting it up with GitHub Actions and Playwright, streamlining your workflow.
11
+
Argos now seamlessly integrates with Vercel Preview for visual testing, offering a streamlined approach to catch visual regressions in a production-like environment. In this step-by-step guide, I show my journey to run Argos on Vercel Preview via GitHub Actions, and share my source code to do so.
13
12
14
13
<MainImage />
15
14
16
-
## Motivation behind this feature
15
+
## Why Visual Testing with Vercel Preview? Key Advantages
17
16
18
-
Responding to user feedback, we recognized the need for visual testing directly on Vercel Previews, especially for environments akin to production settings. This approach is not only cost-effective, eliminating the need for separate test environments, but also enhances test accuracy by mirroring production conditions closely.
17
+
-**Reducing CI cost:** Eliminating the need to set up a second environment to run the tests.
18
+
-**Increasing test reliability**: Visual testing on a production-like environment.
19
+
-**Increasing test reliability**: Visual testing on a production-like environment.
19
20
20
-
## How to run Argos on Vercel Preview
21
+
**Note:** This method is optimal for repeatable tests that don't significantly alter the environment, as certain tests (e.g. those involving user deletion) may not be applicable.
21
22
22
-
### 1. Set up Argos
23
+
##Getting Started with Argos: Setup Guide
23
24
24
-
Start by following the Q[Quickstart guide](https://argos-ci.com/docs) to integrate Argos with Playwright. This foundational step ensures that Argos is ready to run visual tests during your CI process.
25
+
### Prerequisites
25
26
26
-
### 2. Run tests on your Vercel Preview
27
+
Before integrating Argos into Vercel Preview for visual testing, I have:
27
28
28
-
Adapt your CI workflow with this GitHub Actions configuration to enable Argos visual testing on Vercel Previews:
29
+
1. Set up a [Next.js](https://nextjs.org/) project with [Playwright](https://playwright.dev).
30
+
2. Integrated Playwright tests into CI/CD.
31
+
3. Deployed the project on Vercel.
32
+
33
+
### 1. Project Importation to Argos
34
+
35
+
[Signed up into Argos](https://app.argos-ci.com/signup) and import my project. In response, Argos generated an `ARGOS_TOKEN` for my repository that I saved it for later usage.
I utilized the [Screenshot pages script](https://argos-ci.com/docs/screenshot-pages-script) from Argos's documentation for capturing my application's homepage. This script is flexible for adding more pages in the future.
First, I set up `ARGOS_TOKEN` as a repository secret on GitHub. Then, I'm ready to push my code to GitHub monitor the status checks to ensure everything is working as expected: Playwright, Vercel, and Argos.
98
+
99
+

100
+
101
+
## Run Argos on Vercel Preview
102
+
103
+
To run my tests on Vercel Preview, I updated my CI workflow file:
29
104
30
105
```yml
31
106
name: Playwright + Argos Tests
107
+
# 👉 Trigger on deployment event
32
108
on: deployment_status:
33
109
jobs:
34
110
test:
111
+
# 👉 Run tests only if the deployment is successful
For a comprehensive explanation of each step, consult the [Argos documentation](https://argos-ci.com/docs/run-on-preview-deployment).
128
+
For a comprehensive explanation of each step, read [Argos documentation](https://argos-ci.com/docs/run-on-preview-deployment).
51
129
52
-
Next, update your Playwright config file is updated to reflect the preview's URL and configure it to ignore the Vercel toolbar for cleaner test results:
130
+
Then, I updated my Playwright's config file:
53
131
54
132
```ts
55
133
export default defineConfig({
56
134
use: {
57
-
# 👉 URL generated for the preview
135
+
// URL generated for the preview
58
136
baseURL: process.env.BASE_URL,
59
137
},
60
138
extraHTTPHeaders: {
61
-
# 👉 Hide vercel toolbar in tests
139
+
// Hide vercel toolbar in tests
62
140
"x-vercel-skip-toolbar": "0",
63
141
},
64
142
});
65
143
```
66
144
67
-
Assuming you have automatic deploys set up, you’ll see the results of your deploy in your pull request. Upon a successful deploy, the E2E workflow will start on the preview.
145
+
After my changes are merged, upon a successful deploy, the E2E workflow start on the preview:
Leveraging Argos with Vercel Previews not only enhances visual consistency in a near-production environment but also optimizes your CI process by eliminating the need for additional environments for testing. This integration streamlines your workflow, ensuring that your projects meet the highest standards of visual quality while being cost-effective.
161
+
Vercel Preview and Argos serve complementary roles in ensuring web development excellence. Vercel Preview focuses on verifying expected outcomes, while Argos excels at detecting visual regressions across various viewports. Together, they strengthen the development workflow, allowing developers to harness the best of both tools for unparalleled visual consistency and reliability.
0 commit comments