What is E2E Testing? - spryker-projects/cypress-boilerplate GitHub Wiki

End-to-End (E2E) testing is a technique that tests your entire application, from the web browser through to the back end, including integrations with third-party APIs and services. E2E testing ensures that your app functions as a cohesive whole, verifying that all components work together as expected.

How Does E2E Testing Work?

In E2E testing, the test simulates real user interactions by running in a real browser. The test visits URLs, interacts with content, clicks buttons, fills out forms, and navigates through the app exactly as a user would. This ensures that the tests closely match the actual user experience, helping to identify issues that users might encounter.

With Cypress, developers, QA teams, or specialized testing engineers can write E2E tests using an API that mirrors the steps a user would take. These tests help verify the integrity of your application across the entire stack, ensuring that everything from the front end to the back end functions as intended.

Benefits of E2E Testing

E2E tests offer several key benefits:

  • Ensures app functionality as a cohesive whole: E2E testing checks how all parts of your application, from the front end to the back end, work together.
  • Matches the user experience: Because E2E tests simulate real user interactions, they are great for verifying that your app behaves exactly as it would for an actual user.
  • Cross-functional testing: E2E tests can also serve as integration tests by ensuring that external services and APIs work correctly with your app.
  • Developer and QA involvement: E2E tests can be written by developers, QA engineers, or testing specialists, making them flexible and collaborative across teams.

Considerations for E2E Testing

While E2E testing is powerful, there are some challenges and considerations:

  • Setup and maintenance complexity: E2E tests can be harder to set up, run, and maintain compared to other types of tests like unit or integration tests. This is especially true when provisioning the necessary infrastructure in CI environments.
  • Testing infrastructure: Some scenarios, like testing third-party API integrations or complex workflows, might require additional setup or more sophisticated testing environments.
  • Flakiness and speed: Since E2E tests cover the entire application, they tend to be slower and are more susceptible to flakiness compared to isolated unit tests.

Common Scenarios for E2E Testing

E2E tests are particularly useful for verifying key workflows and system integrity. Some common scenarios where E2E tests should be used include:

  • Critical workflows: Validate key user journeys such as authentication, purchasing, or registration flows.
  • Data persistence: Ensure data is properly saved, updated, and displayed across different pages and screens.
  • Smoke tests: Run quick, broad tests to check the health of the system before deployment.

E2E Testing Characteristics

Topic E2E Testing
What's Tested All app layers (front end, back end, APIs, third-party services)
Characteristics Comprehensive, slower, and more susceptible to flakiness
Used For Verifying that the app works as a cohesive whole
Written By Developers, QA Teams, SDETs (Software Development Engineers in Test)
CI Infrastructure May require complex setup
Initialization Command cy.visit(url)

Conclusion

E2E testing is a crucial tool for ensuring the overall functionality and reliability of your application. While it can be more complex to set up and maintain, the benefits of catching critical errors and ensuring smooth user experiences make it invaluable for any robust testing strategy. By covering critical workflows, verifying integration points, and using real browsers to simulate user behavior, E2E testing with Cypress helps ensure your application is working exactly as your users expect.