Member-only story
Accurately Measuring API Response Time with Cypress

In testing web applications, API response times are important for assessing performance and user experience. Developers, though, tend to observe differences between response times recorded in tests and those shown in the browser’s developer tools.
This article investigates the correct way to measure API response time using Cypress with a minimal number of external influencing factors.
Why Is There a Difference in Response Time?
If we’ve tried to measure an API request’s response time when we click a button, we might notice that Cypress’s reported response time is much bigger than seeing in the network tab of our browser. This is because:
- Frontend Processing Overhead : Cypress measures the entire process, including JavaScript execution and rendering, whereas the network tab distinguishes API requests.
- Browser & JavaScript Execution Delays : Cypress runs in a Node.js process and therefore could result in minimal execution delays.
- Intercept Handling Time: Cypress Cypress cy.intercept() includes an extra step where the request is intercepted, forwarded, and then processed before being returned to the test.