Visual Testing for Angular with Cypress
Visual testing for Angular with Cypress adds screenshot comparisons to the Cypress specs you already run, so styling and layout regressions in your Angular app are caught next to the functional checks. Cypress has no visual comparison of its own; the @wopee-io/wopee.cy plugin adds cy.wopeeTrack(), which waits for the page's web fonts and images, takes the screenshot, and compares it with the approved baseline in Wopee.io, where you approve or reject each difference.
Why visual testing Angular with Cypress is hard
Angular and Cypress work well together for functional tests, but screenshots expose details functional tests never see. Angular Material uses the Material Icons font, which renders icon names as plain text until the font has loaded, so an early screenshot shows the word close where an X should be. Roboto and other web fonts swap in late, Material components animate on open, and dialogs and snack bars render in the CDK overlay container at the end of the page. Cypress itself does not compare screenshots: teams pick a community snapshot plugin, store baseline images in the repository, and handle differences between local machines and CI by hand. When an Angular Material upgrade restyles every button, the result is hundreds of failed snapshots and a large binary diff in the pull request.
How Wopee.io adds visual checks to Cypress
The Wopee.io Cypress plugin is built for exactly this. You register addWopeePlugin(on, config) in cypress.config.js, call addWopeeCommands() in the support file, and map your API key and project into the wopee object in env. In a spec, cy.wopeeStartSuite and cy.wopeeStartScenario group the screenshots, and cy.wopeeTrack({ stepName }) waits for web fonts and images (up to five seconds by default, from plugin 4.13.4) before it captures the full page, which removes the Material Icons ligature problem. Chain it after cy.get() to capture one element, and pass ignoreAreas with CSS selectors for regions that change on purpose, such as a last-updated time; a selector that matches nothing is skipped. Baselines live in Wopee.io per branch, so a Material upgrade becomes one review session in Wopee Commander where you approve the intended restyle in bulk and reject the real regressions. By default a difference leaves the run green; set enableSoftAssert: false to fail the test instead. The plugin supports Cypress 13 to 16. For coverage beyond your own specs, see AI testing for Angular, and for all options the Cypress plugin reference.
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 a .env file.
- 2Install with npm install -D @wopee-io/wopee.cy dotenv, register addWopeePlugin in setupNodeEvents, and map apiKey and projectUuid into env.wopee in cypress.config.js.
- 3Add addWopeeCommands() to cypress/support/e2e.js so cy.wopeeTrack and the suite and scenario commands exist.
- 4In each spec, start the suite in before, the scenario in beforeEach, and call cy.wopeeTrack where the Angular view has rendered, adding ignoreAreas for live values.
- 5Run npx cypress run, approve the first screenshots in Commander, and review unresolved steps on every later run.
Example: a Cypress test with visual checks
/// <reference types="cypress" />
/// <reference types="@wopee-io/wopee.cy" />
const suiteName = `Angular orders ${new Date().toISOString().slice(0, 16)}`;
describe(suiteName, () => {
before(() => cy.wopeeStartSuite(suiteName));
beforeEach(() => cy.wopeeStartScenario('Orders: list and details'));
afterEach(() => cy.wopeeStopScenario());
it('orders list and details', () => {
cy.visit('/orders');
cy.get('table').should('be.visible');
// Waits for Roboto and Material Icons before the screenshot.
cy.wopeeTrack({ stepName: 'Orders list', ignoreAreas: ['.last-updated'] });
cy.contains('tr', 'Order 1001').click();
cy.get('mat-dialog-container').should('be.visible');
cy.get('mat-dialog-container').wopeeTrack({ stepName: 'Order details dialog' });
});
});
From manual effort to AI-assisted testing
More automation. Less maintenance. Faster review.
Manual check before release
- Visual comparison
- By eye
- Fonts and icon fonts
- Noticed if someone looks
- Dynamic regions
- Judged by eye
- Fail on difference
- No
Community snapshot plugins
- Visual comparison
- Local image diff, baselines in repo
- Fonts and icon fonts
- Wait written by hand
- Dynamic regions
- Masking per plugin
- Fail on difference
- Usually fails at once
- Visual comparison
- Baselines in Wopee.io, review in Commander
- Fonts and icon fonts
- Waits for fonts and images (4.13.4+)
- Dynamic regions
- ignoreAreas by CSS selector or rectangle
- 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
Cypress 13 to 16 with @wopee-io/wopee.cy 4.13.4 or newer. Cypress 16 needs Node.js 22 or 24. Older plugin versions, 4.12.2 and below, only work with Cypress 13 and 14.
Material Icons is a font that renders icon names as text until it loads. From version 4.13.4, cy.wopeeTrack waits for the page's web fonts and images before taking the screenshot, so the icons are drawn. On slow pages raise waitForAssetsTimeout.
Yes. Chain cy.wopeeTrack after cy.get, for example on mat-dialog-container, to capture one element. Wait until it is visible first, so the opening animation has finished.
Related
All AI testing guides →AI Testing for Angular
AI testing for Angular apps. Wopee.io auto-generates and self-heals e2e and visual tests that survive change detection, zones, and component refactors.
Visual Testing for Angular with Playwright
Visual testing for Angular with Playwright: add Wopee.io checks to your Playwright tests, keep baselines out of the repo, and review every diff in one place.
Visual Testing for Angular with WebdriverIO
Visual testing for Angular with WebdriverIO: the Wopee.io service adds browser.trackScreen to your specs and keeps baselines and reviews in one place.