Skip to main content
coding intermediate

Write End-to-End Tests

Generate comprehensive end-to-end test cases for your web applications. Create robust test scenarios that catch bugs before production.

Works with: chatgptclaudegemini

Prompt Template

You are an expert QA engineer specializing in end-to-end testing. I need you to write comprehensive E2E test cases for a web application. Application Details: - Application type: [APPLICATION_TYPE] - Key features to test: [KEY_FEATURES] - Testing framework: [TESTING_FRAMEWORK] - Target browsers: [TARGET_BROWSERS] - User roles: [USER_ROLES] Please create detailed E2E test scenarios that include: 1. **Test Setup**: Initial configuration, test data, and prerequisites 2. **User Journey Tests**: Complete workflows from start to finish 3. **Critical Path Testing**: Essential business flows that must work 4. **Cross-browser Compatibility**: Tests for different browsers 5. **Error Handling**: Tests for edge cases and error scenarios 6. **Performance Considerations**: Basic performance validations For each test case, provide: - Test name and description - Prerequisites and test data setup - Step-by-step test actions - Expected results and assertions - Error handling and cleanup - Code implementation using the specified framework Focus on realistic user scenarios and ensure tests are maintainable, reliable, and cover the most critical functionality. Include both positive and negative test cases. Make the tests robust enough to catch real bugs while being resistant to flaky failures.

Variables to Customize

[APPLICATION_TYPE]

Type of web application being tested

Example: E-commerce website with user authentication, product catalog, shopping cart, and checkout process

[KEY_FEATURES]

Main features that need E2E testing

Example: User login/registration, product search and filtering, add to cart, checkout flow, payment processing, order confirmation

[TESTING_FRAMEWORK]

E2E testing framework to use

Example: Cypress

[TARGET_BROWSERS]

Browsers to test compatibility

Example: Chrome, Firefox, Safari

[USER_ROLES]

Different types of users in the system

Example: Guest users, registered customers, premium members, administrators

Example Output

# E2E Test Suite for E-commerce Application ## Test Setup ```javascript // cypress/support/commands.js Cypress.Commands.add('loginAsCustomer', () => { cy.visit('/login') cy.get('[data-cy=email]').type('customer@test.com') cy.get('[data-cy=password]').type('password123') cy.get('[data-cy=login-btn]').click() }) ``` ## Test Case 1: Complete Purchase Journey ```javascript describe('Purchase Flow', () => { it('should complete end-to-end purchase as registered user', () => { // Setup cy.loginAsCustomer() // Search and select product cy.get('[data-cy=search-input]').type('laptop') cy.get('[data-cy=search-btn]').click() cy.get('[data-cy=product-card]').first().click() // Add to cart cy.get('[data-cy=add-to-cart]').click() cy.get('[data-cy=cart-notification]').should('contain', 'Added to cart') // Checkout process cy.get('[data-cy=cart-icon]').click() cy.get('[data-cy=checkout-btn]').click() // Fill shipping info cy.get('[data-cy=shipping-address]').type('123 Main St') cy.get('[data-cy=continue-btn]').click() // Payment cy.get('[data-cy=card-number]').type('4111111111111111') cy.get('[data-cy=place-order]').click() // Verification cy.url().should('include', '/order-confirmation') cy.get('[data-cy=order-number]').should('exist') }) }) ``` ## Test Case 2: Error Handling ```javascript it('should handle payment failures gracefully', () => { cy.loginAsCustomer() // ... add product to cart steps ... // Invalid card cy.get('[data-cy=card-number]').type('4000000000000002') cy.get('[data-cy=place-order]').click() cy.get('[data-cy=error-message]').should('contain', 'Payment failed') cy.url().should('include', '/checkout') }) ```

Pro Tips for Best Results

  • Use data-cy attributes instead of CSS selectors for more stable test targeting
  • Implement custom commands for common actions like login to reduce code duplication
  • Include both happy path and edge case scenarios in your test suite
  • Add explicit waits for dynamic content and API calls to prevent flaky tests
  • Create separate test data for each test run to ensure test isolation

Tags

Want 500+ Expert Prompts?

Get the Premium Prompt Pack — organized, tested, and ready to use.

Get it for $29

Related Prompts You Might Like