How to Set Up Cypress for E2E Testing

Component testing, network interception, custom commands - the Cypress setup that keeps E2E tests reliable.

Cypress is the most popular E2E testing framework for web applications - and the most commonly set up incorrectly. Tests that rely on arbitrary wait() calls, tests that share state between runs, and tests that hit live external APIs produce a flaky suite nobody trusts. This guide covers the Cypress configuration and patterns that produce reliable tests.

No fluff. Real test coverage from QA engineers who find bugs before your users do.

Cypress vs Playwright: When to Use Each in 2025

Cypress strengths: developer-friendly debugging experience, time-travel debugger, built-in component testing, network interception, excellent documentation. Best for teams who want the best DX for writing and debugging tests, and primarily test Chrome. Playwright strengths: true multi-browser (Chromium Firefox WebKit), faster in CI, better for cross-browser coverage, built-in mobile emulation. Best for teams needing cross-browser coverage or already using Playwright elsewhere. For most React and Vue frontend teams: Cypress for component tests and critical Chrome E2E paths, Playwright for cross-browser E2E.

At Valletta Software, we focus on:

cy.intercept(): stub all external API calls - tests should not depend on external services

Custom commands: cy.login() cy.createUser() - encapsulate repeated setup in reusable commands

Fixtures: test data in cypress/fixtures JSON files - not hardcoded in tests

Before hooks: use beforeEach for test state setup - not shared global state between tests

Viewport: set viewport in cypress.config.js - consistent across all tests

cy.session(): cache login state across tests - dramatically reduces test suite duration

Component testing: test React/Vue components in Cypress - faster than full E2E for isolated components

The Cypress CI Configuration That Eliminates Flakiness

Flaky Cypress tests have specific causes. Each has a specific fix.

We give you more than just people. We give you top performers who drive results.

cy.wait(2000): never use arbitrary waits - use cy.get() with built-in retry or cy.intercept() alias
Selector strategy: data-cy attributes on elements under test - CSS selectors break on refactor
Test isolation: each test creates its own data - never rely on data from a previous test
Parallelization: Cypress Cloud or open-source equivalent - split tests across runners by spec file
Video on failure: record video only on test failure - reduces CI artifact storage by 90%
Retry on failure: retries config in cypress.config.js - retry failed tests once before failing
Dashboard: Cypress Cloud or local dashboard with failure analysis - not just console output

Generate test cases from specs and user stories automatically

Run visual regression across hundreds of screens in minutes

Build CI test gates that catch regressions before merge

Analyze test results and prioritize fixes by business impact

How to Set Up Cypress for E2E Testing - With QA Engineers Who Keep the Suite Green

Lets keep it simple.

Our QA engineers use AI to write test cases from specs, generate edge-case scenarios automatically, and run visual regression checks across hundreds of screens in minutes - so they spend time on the bugs that matter, not the obvious ones.

Lets keep it simple.

Lets keep it simple.

Our QA engineers configure Cypress with custom commands, cy.session login caching, cy.intercept API stubs, and data-cy selectors - suites that run in under 5 minutes and don't flake

Shipping Without QA is Gambling. Lets Fix That.

Our QA engineers have caught the bugs that would have cost you clients. Lets talk.

Rates from EUR 45/h • Free consultation • No commitment required • Response within 24 hours