WebdriverIO visual testing quickstart
Set up visual testing in your WebdriverIO tests with the Argos WebdriverIO SDK.
To add visual testing to WebdriverIO, the Node.js test automation framework for web and mobile applications, install @argos-ci/webdriverio and @argos-ci/cli, call argosScreenshot(browser, "name") in your tests, then upload the screenshots with npm exec -- argos upload ./screenshots/argos in CI with the ARGOS_TOKEN environment variable set. Argos compares every screenshot with a baseline build picked from your Git history and reports the changes as a check on your pull request.
What Argos adds
Baselines from your Git history. There are no reference images to commit or update.
Review on the pull request. Visual changes become a pull request check that your team approves or rejects.
Flaky test detection. Argos flags unstable tests with a flaky badge and a stability score.
Prerequisites
Node.js 22 or later
WebdriverIO set up in your project
Install
Install the Argos CLI and the Argos WebdriverIO SDK:
npm i --save-dev @argos-ci/cli @argos-ci/webdriverioyarn add --dev @argos-ci/cli @argos-ci/webdriveriopnpm add --save-dev @argos-ci/cli @argos-ci/webdriveriobun add --dev @argos-ci/cli @argos-ci/webdriverioNo configuration is needed — the SDK works directly in your tests.
Capture screenshots
Use the argosScreenshot helper to capture screenshots in your tests:
import { browser } from "@wdio/globals";
import { argosScreenshot } from "@argos-ci/webdriverio";
describe("Integration test with visual testing", () => {
it("covers homepage", async () => {
await browser.url("http://localhost:3000");
await argosScreenshot(browser, "homepage");
});
});Screenshots are written to the ./screenshots/argos directory. Add screenshots/ to your .gitignore file to avoid committing them.
Set up CI
Run your WebdriverIO tests in CI, then upload the screenshots to Argos with the CLI:
name: Argos
on:
pull_request:
push:
branches:
- main
jobs:
argos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 22
- run: npm ci
- name: Run WebdriverIO tests
run: npm test
- name: Upload screenshots to Argos
run: npm exec -- argos upload ./screenshots/argos
env:
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }}ARGOS_TOKEN is the project token from Settings → General → Token. On GitHub Actions, you can also use OIDC or tokenless authentication to avoid managing a secret. For GitLab CI, CircleCI, Buildkite, and other providers, see Run Argos in CI.
You're all set
Push your changes and open a pull request — the Argos check appears on it once the build is uploaded. Review the visual changes, approve or reject them, and merge with confidence.
Frequently asked questions
Next steps
Stabilize screenshots – Prevent flaky diffs before they reach your pull requests
WebdriverIO SDK reference – All options
CLI reference – All upload options
Need help? Join our Discord, open an issue on GitHub, or send us an email.
Last updated
Was this helpful?