The Testing Approach
Find out how Cypress provides new ways of testing our web application and what the trade-offs are for the benefits.
Having control of both inside and outside the browser has paved the way to a new kind of testing approach that was never possible before. In this lesson, we will go over a couple of points on how Cypress approaches testing.
Cypress’s new ways of testing
As Cypress has control of almost everything, it means we can alter almost every aspect of our application’s behavior during the testing phase. This lets us create robust and stable test cases that will run regardless of how many asynchronous functions we have or how bad the network connection is at the time of execution.
Stubbing
We’ve seen that Sinon.js is bundled inside Cypress, which makes it easy to stub, spy, or mock functions. We may often have to force impure functions to behave the same way every time to ensure our test cases are deterministic. This is really straightforward in Cypress. Take the following as an example:
Get hands-on with 1400+ tech skills courses.