Skip to main content
Visual Testing · Stack

Visual Testing for Vue with Playwright

Visual testing for Vue with Playwright compares screenshots of your Vue app with approved baselines at the points your Playwright tests choose, the end-to-end option create-vue offers next to Cypress. The @wopee-io/wopee.pw package sends each screenshot to Wopee.io, and labels such as viewport and custom tags keep separate baselines for each locale, theme, or screen size, so one test can cover all of them.

Why visual testing Vue with Playwright is hard

Vue apps rarely look one way. A single view often ships in several languages with vue-i18n, in light and dark themes, and at desktop and mobile widths, and each combination can break on its own: a German label overflows a button, a dark theme loses contrast on a card, a mobile menu overlaps the header. Covering that with Playwright's built-in toHaveScreenshot multiplies PNG files in the repository by every browser, OS, locale, and theme, and keeping them current after a design change is a chore nobody wants. On top of that, Vue Router lazy-loads route components, transitions animate content in, and data-driven v-if blocks appear after navigation, so screenshots need to wait for the finished view.

How Wopee.io adds visual checks to Playwright

Wopee.io handles the combinations with labels instead of file names. Every screenshot's baseline is identified by scenario and step name plus the branch and the optional OS, browser, viewport, device, and custom tags labels, so passing customTags: 'de' or viewport: '390x844' to a track call keeps a separate baseline for each locale or screen size without separate tests. Set the same labels for a whole run with WOPEE_CUSTOM_TAGS and WOPEE_VIEWPORT when a CI job runs one locale. In the test, wait for the routed view and its data, then call trackFullPage, trackViewport, or trackElement with a role-based locator. Differences appear in Wopee Commander per step, where you approve intended changes and reject regressions; nothing is written to the repository, and the Playwright test fails on a difference only if you assert on the returned status. For Cypress users, visual testing for Vue with Cypress covers the plugin; SvelteKit teams can follow visual testing for Svelte with Playwright; and agent-generated Vue coverage is in AI testing for Vue. Setup: Playwright guide.

How to get started

  1. 1
    Create a Wopee.io project with the test framework set to Playwright and put WOPEE_API_URL, WOPEE_PROJECT_UUID, and WOPEE_API_KEY in .env.
  2. 2
    Install @wopee-io/wopee.pw and add '@wopee-io/wopee.pw/wopee-reporter' to the reporters in playwright.config.ts, with baseURL pointing at the Vite dev server or a preview build.
  3. 3
    Start a suite in beforeAll and a scenario per test in beforeEach, passing testInfo, and stop it in afterEach.
  4. 4
    Pass customTags or viewport to each track call, or set WOPEE_CUSTOM_TAGS and WOPEE_VIEWPORT per CI job, so every locale and screen size has its own baseline.
  5. 5
    Run npx playwright test, approve the first screenshots in Commander, and review unresolved steps on later runs.

Example: a Playwright test with visual checks

tests/account.visual.spec.ts
import { test } from '@playwright/test';
import { Wopee } from '@wopee-io/wopee.pw';

const wopee = new Wopee();
const locales = ['en', 'de'];

test.beforeAll(async () => {
await wopee.startSuite(`Vue visual ${new Date().toISOString().slice(0, 16)}`);
});
test.beforeEach(async ({}, testInfo) => {
await wopee.startScenario(testInfo.title, testInfo);
});
test.afterEach(async () => {
await wopee.stopScenario();
});

for (const locale of locales) {
test(`Account page (${locale})`, async ({ page }) => {
await page.goto(`/${locale}/account`);
await page.getByRole('main').getByRole('heading', { level: 1 }).waitFor();
// customTags is part of the baseline identity: one baseline per locale.
await wopee.trackFullPage({ page, stepName: 'Account', customTags: locale });
});
}

From manual effort to AI-assisted testing

More automation. Less maintenance. Faster review.

Manual check before release

Locales and themes
A few spot checks
Screen sizes
Devices at hand
Where baselines live
None
Review
By eye

Playwright toHaveScreenshot

Locales and themes
One PNG per combination in the repo
Screen sizes
Per Playwright project
Where baselines live
Repo, per browser and OS
Review
HTML report per run
Wopee.ioWopee.io
AI testing
Locales and themes
customTags label per locale or theme
Screen sizes
viewport and device labels
Where baselines live
Wopee.io, per branch and labels
Review
Approve or reject per step in Commander

Add visual checks to your Playwright tests

Keep your tests, add a few track calls, and review every visual change in one place.

Frequently asked questions

Pass customTags with the locale to the track call, or set WOPEE_CUSTOM_TAGS for the whole run. Custom tags are part of the baseline identity, so each locale is compared only with its own approved screenshot.

No. Wopee.io works from the Playwright test: add the reporter, start and stop the suite and scenario in the hooks, and add track calls where the view has finished rendering.

Only if you check the returned status, for example expect(result?.status).not.toBe('unresolved'). Otherwise the test passes and the step waits for review in Wopee Commander.