Create Cypress E2E Test Suite
testing
TypeScript
testing
zen
Generate comprehensive Cypress E2E tests with custom commands, API mocking, and configuration.
By ethan_w
12/8/2025
Prompt
Create a complete Cypress E2E test suite for [APPLICATION_NAME] with the following specifications:
Requirements
- Application name: [APPLICATION_NAME]
- Base URL: [BASE_URL]
- Test flows to cover: [FLOW_1], [FLOW_2], [FLOW_3]
- Authentication method: [Session/Token/Cookie]
- API endpoints to mock: [ENDPOINT_1], [ENDPOINT_2]
- File upload scenarios: [YES/NO]
- Test data location: [FIXTURES_PATH]
- Viewport sizes to test: [DESKTOP/MOBILE/TABLET]
- Screenshot on failure: [YES/NO]
Deliverables
Generate complete Cypress test code including:
Test spec files for each [FLOW]:
- Descriptive test suite with describe()
- beforeEach() hooks for setup
- Individual test cases with it()
- Proper assertions using should() and expect()
- Use data-cy attributes for selectors
- URL validation after navigation
- Element visibility and content checks
Custom commands in cypress/support/commands.ts:
- TypeScript type declarations for Chainable interface
- Reusable login command with cy.session()
- dataCy() helper for data-cy selectors
- Any flow-specific commands for [APPLICATION_NAME]
API intercepts and mocking:
- cy.intercept() for [ENDPOINTS]
- Mock response bodies with realistic data
- Alias routes with .as()
- Wait for requests with cy.wait()
- Test both success and error responses
Configuration in cypress.config.ts:
- baseUrl set to [BASE_URL]
- Viewport dimensions for [VIEWPORT_SIZES]
- Video and screenshot settings
- Test retry configuration
- Environment variable handling
Fixtures if needed:
- JSON fixtures for mock data
- Test files for upload scenarios
- User credentials and test data
Best practices implementation:
- Independent tests (no shared state)
- Proper wait strategies (avoid arbitrary waits)
- Accessibility testing where applicable
- Page Object pattern for complex flows
Output production-ready Cypress tests ready to run in CI/CD.
Tags
cypress
e2e
testing
automation
Tested Models
gpt-4
claude-3-5-sonnet