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: poi
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 integrates with Vercel Preview for visual testing, offering a streamlined approach to catch visual regressions in a production-like environment — without the hassle of complex setups. his guide will walk you through implementing Argos with Vercel Preview via GitHub Actions, complete with source code insights.
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
+
-**Direct Visual Verification:** Allows for immediate identification of visual changes in pull requests, ensuring what you see is what you get in production.
18
+
-**Cost Reduction:** Reduces CI expenses by eliminating the need to duplicate test environments.
19
+
-**Production-like Environment Testing:** Offers a closer approximation to the live site, increasing test reliability.
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 ensured:
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
+
I [signed up into Argos](https://app.argos-ci.com/signup) and imported my project. Once done, Argos display an `ARGOS_TOKEN` for this repository. I saved it for the next step.
36
+
37
+
I [signed up into Argos](https://app.argos-ci.com/signup) on Argos and added my project. After this, Argos generated an `ARGOS_TOKEN` for my repository. I saved it for later.
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 pushed my branch to Github and monitored the status checks to ensure everything was functioning as expected: Playwright, Vercel, and Argos.
100
+
101
+

102
+
103
+
## Run Argos on Vercel Preview
104
+
105
+
To run my tests on Vercel Preview, I updated my CI workflow file:
29
106
30
107
```yml
31
108
name: Playwright + Argos Tests
109
+
# 👉 Trigger on deployment event
32
110
on: deployment_status:
33
111
jobs:
34
112
test:
113
+
# 👉 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).
130
+
For a comprehensive explanation of each step, read [Argos documentation](https://argos-ci.com/docs/run-on-preview-deployment).
51
131
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:
132
+
Then, I updated my Playwright's config file:
53
133
54
134
```ts
55
135
export default defineConfig({
56
136
use: {
57
-
# 👉 URL generated for the preview
137
+
// URL generated for the preview
58
138
baseURL: process.env.BASE_URL,
59
139
},
60
140
extraHTTPHeaders: {
61
-
# 👉 Hide vercel toolbar in tests
141
+
// Hide vercel toolbar in tests
62
142
"x-vercel-skip-toolbar": "0",
63
143
},
64
144
});
65
145
```
66
146
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.
147
+
After this my are merged, upon a successful deploy, the E2E workflow start on the preview:
Explore my GitHub for a detailed guide on integrating Argos with Vercel Preview, particularly highlighted in Pull Request #2 and the live Vercel deployment:
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.
163
+
Integrating Argos and Vercel Preview offers a practical solution for improving visual testing in CI workflows. This setup simplifies identifying visual changes, ensuring your projects look as intended before going live. By following this guide, you're equipped to implement an effective visual testing strategy that minimizes errors and enhances the reliability of your deployments, all within the familiar environment of your existing CI/CD pipeline.
0 commit comments