Visual Testing for Vue with Cypress
Visual testing for Vue with Cypress adds screenshot comparisons to the Cypress specs that many Vue projects start with, since create-vue offers Cypress as an end-to-end option. The @wopee-io/wopee.cy plugin adds cy.wopeeTrack(), which waits for fonts and images, captures the page or one element, and compares it with the approved baseline in Wopee.io, where you approve or reject each change.
Why visual testing Vue with Cypress is hard
Vue makes it easy to build polished interfaces, and that polish is what screenshots trip over. <Transition> and <TransitionGroup> animate elements in and out, so a screenshot taken mid-animation captures a half-faded list. Component libraries such as Vuetify, PrimeVue, or Element Plus restyle many screens at once with a single upgrade, and v-if blocks that appear after data loads change the layout seconds after navigation. Scoped styles add data-v- attributes that change with the build, which matters for element selectors. Cypress catches the behaviour but not the look, and its screenshots have no comparison built in, so teams either skip visual checks or keep a folder of baseline images in the repository and fight it on every library upgrade.
How Wopee.io adds visual checks to Cypress
With the Wopee.io plugin, visual checks become one more command in the Vue specs you already have. Register addWopeePlugin(on, config) in cypress.config.js, add addWopeeCommands() to the support file, and start a suite and scenario in the hooks. Before each cy.wopeeTrack, wait for the state the user sees after transitions finish, for example cy.get('[data-test=todo-list] li').should('have.length', 3), then capture; the command itself waits for web fonts and images (plugin 4.13.4 and newer). Chain it after cy.get() to capture a single component such as a Vuetify card, using data-test attributes rather than generated data-v- attributes. Live regions go into ignoreAreas by selector. When a component library upgrade restyles the app, the review is a single session in Wopee Commander, where intended changes are approved in bulk and regressions rejected; set enableSoftAssert: false if an unresolved step should fail the run. If you are choosing between tools, visual testing for Vue with Playwright covers the other create-vue option, and AI testing for Vue covers agent-generated tests. Setup: Cypress guide.
How to get started
- 1Create a Wopee.io project with the test framework set to Cypress and copy WOPEE_PROJECT_UUID and a new WOPEE_API_KEY into .env.
- 2Install @wopee-io/wopee.cy and dotenv in the Vue project, register addWopeePlugin in setupNodeEvents, and map the key and project into env.wopee.
- 3Add addWopeeCommands() to cypress/support/e2e.js (or e2e.ts in a TypeScript project).
- 4In each spec, wait for the post-transition state with a Cypress assertion, then call cy.wopeeTrack on the page or a single component.
- 5Run npx cypress run against the Vite dev server or a preview build, approve the first screenshots in Commander, and review later differences.
Example: a Cypress test with visual checks
/// <reference types="cypress" />
/// <reference types="@wopee-io/wopee.cy" />
const suiteName = `Vue todos ${new Date().toISOString().slice(0, 16)}`;
describe(suiteName, () => {
before(() => cy.wopeeStartSuite(suiteName));
beforeEach(() => cy.wopeeStartScenario('Todos: list and edit card'));
afterEach(() => cy.wopeeStopScenario());
it('todo list and edit card', () => {
cy.visit('/todos');
// Wait until <TransitionGroup> has finished adding the items.
cy.get('[data-test=todo-list] li').should('have.length', 3);
cy.wopeeTrack({ stepName: 'Todo list' });
cy.contains('[data-test=todo-list] li', 'Buy milk').click();
cy.get('[data-test=edit-card]').should('be.visible').wopeeTrack({ stepName: 'Edit card' });
});
});
From manual effort to AI-assisted testing
More automation. Less maintenance. Faster review.
Manual check before release
- Transitions and late v-if blocks
- Judged by eye
- Component library upgrades
- Spot checks
- Element capture
- If someone looks
- Fail on difference
- No
Community snapshot plugins
- Transitions and late v-if blocks
- Waits written by hand
- Component library upgrades
- Update many image files in the repo
- Element capture
- Screenshot an element
- Fail on difference
- Usually fails at once
- Transitions and late v-if blocks
- Cypress assertion, then cy.wopeeTrack
- Component library upgrades
- Approve intended changes in bulk in Commander
- Element capture
- Chain after cy.get on data-test attributes
- Fail on difference
- Opt in with enableSoftAssert: false
Add visual checks to your Cypress tests
Keep your tests, add a few track calls, and review every visual change in one place.
Frequently asked questions
Yes. If you chose Cypress during setup, install @wopee-io/wopee.cy, register the plugin in cypress.config, and add the commands to the support file. Nothing in the Vue app changes.
Assert on the final state before tracking, for example the number of list items or a visible element, so Cypress waits until the transition is done. cy.wopeeTrack then waits for fonts and images before the screenshot.
No. Scoped-style attributes are generated by the build and can change. Use data-test attributes or text and roles to select the component you chain cy.wopeeTrack after.
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 Playwright
Visual testing for Vue with Playwright: track pages per locale and viewport with Wopee.io labels and review every visual change per branch in Commander.
Visual Testing for React with Cypress
Visual testing for React with Cypress: add cy.wopeeTrack to your specs, ignore live regions by selector, and review every React UI change in Wopee.io.