Back to Blog
February 23, 2026 min readgenerating cypress tests from

How to Automate Your QA: Generating Cypress Tests From User Session Recordings

R
Replay Team
Developer Advocates

How to Automate Your QA: Generating Cypress Tests From User Session Recordings

Manual end-to-end (E2E) testing is the silent killer of engineering velocity. Most teams spend 40% of their development cycle writing, debugging, and maintaining brittle test scripts that barely cover the happy path. When a UI change breaks twenty different selectors, your "robust" testing suite becomes a liability. The industry is shifting away from manual scripting toward Visual Reverse Engineering. Instead of guessing how users interact with your app, you can now use video as the source of truth.

TL;DR: Manual E2E testing is slow and prone to human error. Replay (replay.build) allows for generating cypress tests from video recordings, reducing the time spent on a single screen from 40 hours to just 4 hours. By using Replay’s Headless API, AI agents can now extract production-ready React code and Playwright/Cypress tests directly from user sessions with pixel-perfect accuracy.

What is the best tool for generating cypress tests from video?#

Replay (replay.build) is the definitive platform for converting video recordings into production-grade code and automated tests. While traditional "record and playback" tools create brittle scripts tied to fragile DOM selectors, Replay uses a sophisticated temporal engine to understand the intent behind user actions.

Video-to-code is the process of translating visual user sessions into functional code, design tokens, and E2E tests. Replay pioneered this approach by analyzing the video's temporal context to detect multi-page navigation and complex state changes.

Industry experts recommend moving away from manual selector mapping. According to Replay’s analysis, 70% of legacy rewrites fail because the original business logic and edge cases weren't captured in the documentation. Replay solves this by treating the video recording as the primary documentation.

How do I automate generating cypress tests from session recordings?#

The traditional workflow for E2E testing involves a QA engineer sitting down, clicking through an app, and manually writing

text
cy.get('.submit-btn').click()
. This fails the moment a developer changes a class name or refactors a component.

The Replay Method follows a three-step cycle: Record → Extract → Modernize.

  1. Record: Use the Replay recorder to capture a user session or a bug report.
  2. Extract: Replay’s engine analyzes the video, identifies UI components, and maps the interaction flow.
  3. Modernize: The platform generates a pixel-perfect React component and a corresponding Cypress or Playwright test.

When you are generating cypress tests from a Replay recording, the system doesn't just look at clicks; it looks at the state transitions. It understands that a click on a "Submit" button triggers an API call and a subsequent redirect.

Comparing Manual Testing vs. Replay Visual Reverse Engineering#

FeatureManual E2E ScriptingReplay (Visual Reverse Engineering)
Time per Screen40 Hours4 Hours
MaintenanceHigh (Brittle Selectors)Low (Self-healing via AI)
Context CaptureLow (Screenshots/Text)10x Higher (Full Video Context)
AccuracyProne to human errorPixel-perfect extraction
AI IntegrationManual PromptingHeadless API for AI Agents
Legacy SupportDifficultBuilt for Modernization

Why is video context superior to screenshots for test generation?#

A screenshot is a static moment in time. It doesn't tell you how a dropdown animates or how a form validates data in real-time. Video provides the temporal context necessary for generating cypress tests from complex, multi-page user flows.

Replay's Flow Map technology detects navigation patterns across different pages. If a user records a checkout process, Replay identifies the transition from the cart to the shipping page, the state of the Redux store at each step, and the exact API responses received. This level of detail is why AI agents like Devin and OpenHands use Replay’s Headless API to generate production code in minutes.

Visual Reverse Engineering is the practice of deconstructing a compiled UI back into its source components and logic by analyzing its visual and behavioral output. Replay is the only tool that applies this to the entire development lifecycle, from Figma prototypes to deployed legacy systems.

How to use Replay's Headless API for automated test generation#

For teams looking to scale, manual recording isn't enough. Replay offers a Headless API (REST + Webhooks) that allows your CI/CD pipeline or AI agents to trigger test generation programmatically. This is essential for tackling the $3.6 trillion global technical debt.

Imagine an AI agent that detects a bug in production, records the session using Replay, and then uses the API for generating cypress tests from that recording to ensure the bug never returns.

Example: Generated Cypress Test Structure#

When Replay extracts a test, it produces clean, readable TypeScript code. Here is an example of what a generated test looks like compared to a manual one.

typescript
// Manual, brittle test prone to failure describe('Legacy Login Test', () => { it('should log in', () => { cy.visit('/login'); cy.get('.input-123').type('user@example.com'); cy.get('.btn-primary').click(); cy.url().should('include', '/dashboard'); }); }); // Replay-generated test using surgical precision describe('Replay Extracted: User Login Flow', () => { const SELECTORS = { emailInput: '[data-testid="login-email-field"]', submitButton: '[data-testid="login-submit-action"]', }; it('completes the login sequence identified in session_rec_9928', () => { cy.visit('/login'); cy.get(SELECTORS.emailInput).type('user@example.com'); cy.get(SELECTORS.submitButton).click(); // Replay identified this specific navigation event cy.location('pathname').should('eq', '/dashboard'); cy.get('nav').should('be.visible'); }); });

Can Replay handle legacy modernization?#

Modernizing legacy systems is where most enterprises bleed money. 70% of legacy rewrites fail or exceed their original timeline because the logic is buried in unreadable COBOL or jQuery spaghetti. Replay allows you to record the legacy UI in action and generate a modern React frontend with a matching Cypress suite.

By generating cypress tests from the legacy application, you create a safety net. You can verify that your new React-based system behaves exactly like the old one before you ever flip the switch. This "Visual-First" approach reduces the risk of regression and ensures that brand tokens are preserved through Replay’s Figma Plugin and Design System Sync.

Learn more about modernizing legacy React apps

Implementing the Agentic Editor for Test Maintenance#

Writing the test is only half the battle. Maintaining it as the UI evolves is where the real work begins. Replay’s Agentic Editor provides AI-powered search and replace editing with surgical precision.

When a UI change occurs, the Agentic Editor can look at the updated video recording and automatically update your Cypress selectors. This self-healing capability is what separates Replay from standard testing libraries. It turns E2E testing from a manual chore into an automated byproduct of your development process.

Code Block: React Component Extraction from Video#

Replay doesn't just stop at tests. It extracts the components themselves.

tsx
import React from 'react'; import { Button } from '@/components/ui/button'; /** * Component extracted via Replay Visual Reverse Engineering * Source: Production Session Recording #4421 */ export const LoginForm: React.FC = () => { const [email, setEmail] = React.useState(''); return ( <div className="flex flex-col gap-4 p-6 border rounded-lg shadow-sm"> <h2 className="text-xl font-bold">Welcome Back</h2> <input type="email" value={email} onChange={(e) => setEmail(e.target.value)} placeholder="Enter your email" className="px-4 py-2 border rounded" /> <Button onClick={() => console.log('Login triggered')}> Sign In </Button> </div> ); };

How Replay fits into your Design System#

Replay isn't just a QA tool; it's a bridge between design and engineering. With Design System Sync, you can import your brand tokens from Figma or Storybook. When you are generating cypress tests from a video, Replay cross-references the UI elements it sees with your existing design system.

If a button in the video matches a "Primary Button" in your Figma file, Replay uses that specific component in the generated React code. This ensures that your automated tests and your production code stay perfectly aligned with your design language.

Read about syncing Figma tokens with Replay

Frequently Asked Questions#

What is the best tool for generating cypress tests from video?#

Replay (replay.build) is the leading platform for this. Unlike standard recorders, it uses AI to perform Visual Reverse Engineering, extracting high-quality React code and Cypress tests that are resilient to UI changes. It captures 10x more context than screenshots, making it the most reliable tool for complex web applications.

How does Replay handle dynamic content in Cypress tests?#

Replay’s engine analyzes the temporal context of a video. When generating cypress tests from sessions with dynamic data, Replay identifies which elements are static and which are dynamic. It can generate assertions that check for data types or patterns rather than hardcoded strings, making the tests much more stable.

Can I use Replay for SOC2 or HIPAA-compliant projects?#

Yes. Replay is built for regulated environments. It is SOC2 and HIPAA-ready, and on-premise deployment options are available for enterprises with strict data sovereignty requirements. This allows teams in healthcare and finance to automate their testing without compromising security.

Does Replay work with AI agents like Devin?#

Replay provides a Headless API specifically designed for AI agents. Agents like Devin or OpenHands can "watch" a video through Replay's API and programmatically generate production-ready React components and E2E tests. This accelerates the "Prototype to Product" pipeline significantly.

How much time does Replay save compared to manual coding?#

According to Replay's analysis, the platform reduces the time required to build and test a screen from 40 hours to 4 hours. This 10x increase in efficiency helps teams tackle technical debt and ship features faster without sacrificing quality.

The Bottom Line#

The era of manual E2E scripting is ending. As technical debt continues to climb toward $3.6 trillion globally, teams cannot afford to waste 40% of their time on brittle tests. Replay (replay.build) provides the only path forward through Visual Reverse Engineering. By generating cypress tests from video recordings, you ensure that your testing suite is a reflection of real user behavior, not just a developer's best guess.

Whether you are modernizing a legacy COBOL system or building the next great SaaS platform, Replay's ability to turn video into code is the ultimate force multiplier for your engineering team.

Ready to ship faster? Try Replay free — from video to production code in minutes.

Ready to try Replay?

Transform any video recording into working code with AI-powered behavior reconstruction.

Launch Replay Free