Enable E2E Testing
When E2E testing, we want to address the following issues:
How do we minimize flaky tests?
How do we ensure tests complete within a reasonable amount time?
Minimizing Flakiness
To minimize flaky tests, we should use mocks in place of calling live services. Examples of live services include authentication, internal API's, and external APIs such as Stripe for payments or Twilio for SMS messages. While depending on live services has the following advantages:
Maintenance and updates by a dedicated team
Data created by maintainers
It also incurs the following disadvantages:
Being down unexpectedly
Inconsistent responses due to updates to a shared service
Having long response latencies
These disadvantages are what make E2E tests flaky. To help address the flakiness, we can record requests to create mock APIs. The following provides an overview of how Stoobly can help:
Run the E2E test to trigger sending requests
Stoobly will intercept the request and record it
Configure Stoobly to mock instead of record requests
Run E2E tests, API tests, or UI tests
But using in mocks in place of live services may sound counter-intuitive when it comes to E2E testing. After all, isn't the point of E2E testing to validate real user flows? This is true in the case where mocks are consumer generated. Consumer generated mocks have a tendency to not represent real data. That is, consumers likely do not have the same understanding of API responses as the maintainers of the system that produces it. Furthermore, mocks may become out of date as request contracts change. In Stoobly's case here, mocks are system generated and stored for consumer testing at a later point.
Minimizing Run Time
Latency is affected by the following factors:
Distance between client and server
Network congestion
Number of concurrent clients talking to the server
Server processing time
By replacing the live service with a mock service running locally, we can minimize the impact of all the above factors.
Last updated