Fixtures and Integration
Explore how to use Cypress fixtures to stub network requests, manage static test data, and organize your test files within the integration folder. This lesson helps you create deterministic tests that handle network side effects and customize test structure for effective end-to-end testing.
We'll cover the following...
When creating a test suite for a web application, we have to consider network connection fails. Any function that relies on fetching data from a server or requires sending data to the server has side effects. And side effects can easily break tests.
Our network request can come back either successfully or with a failure, or anything in between. There are just too many status codes to keep in mind. To work around this, Cypress introduces a folder called “fixtures”.
What are fixtures?
Fixtures are pieces of static data that can be used inside our test cases whenever we need to stub a network request.
This way, we can eliminate any side effects, and ensure that our test cases are deterministic. We can also use them to match our data against a fixed set without cluttering the actual test cases.
Configuring fixtures
Let’s take the ...