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
- 1Create 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.
- 2Install @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.
- 3Start a suite in beforeAll and a scenario per test in beforeEach, passing testInfo, and stop it in afterEach.
- 4Pass 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.
- 5Run npx playwright test, approve the first screenshots in Commander, and review unresolved steps on later runs.
Example: a Playwright test with visual checks
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
- 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.
Related
All AI testing guides →AI Testing for Vue.js
AI testing for Vue.js apps. Wopee.io generates and self-heals e2e and visual tests that survive reactivity, scoped styles, and component refactors.
Visual Testing for Vue with Cypress
Visual testing for Vue with Cypress: add cy.wopeeTrack to the Cypress specs create-vue set up, wait out transitions, and review UI changes in Wopee.io.
Visual Testing for Svelte with Playwright
Visual testing for Svelte with Playwright: add Wopee.io checks to the Playwright tests SvelteKit set up and review every visual change per branch.