0
0
Cypresstesting~5 mins

Using fixtures in tests in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a fixture in Cypress testing?
A fixture is a fixed set of data stored in a file that Cypress can load and use in tests to simulate real data or responses.
Click to reveal answer
beginner
How do you load a fixture file in a Cypress test?
Use cy.fixture('filename').then((data) => { ... }) to load the fixture data asynchronously inside your test.
Click to reveal answer
beginner
Why use fixtures instead of hardcoding test data in Cypress tests?
Fixtures keep test data separate from test code, making tests cleaner, easier to maintain, and allowing reuse of data across multiple tests.
Click to reveal answer
intermediate
How can you use fixture data to stub a network request in Cypress?
Load the fixture with cy.fixture() and then use cy.intercept() to stub the request, returning the fixture data as the response.
Click to reveal answer
beginner
Where should fixture files be stored in a Cypress project?
Fixture files should be placed in the cypress/fixtures folder, typically as JSON files.
Click to reveal answer
Which command loads fixture data in Cypress?
Acy.data('file.json')
Bcy.load('file.json')
Ccy.fixture('file.json')
Dcy.read('file.json')
Where are fixture files stored by default in a Cypress project?
Acypress/assets
Bcypress/fixtures
Ccypress/files
Dcypress/data
What is a main benefit of using fixtures in tests?
ASeparates test data from test code
BMakes tests run faster
CAutomatically generates test data
DRemoves the need for assertions
How can fixture data be used with cy.intercept()?
ATo generate random data
BTo load UI components
CTo clear cookies
DTo stub network responses with predefined data
Which file format is commonly used for fixtures?
AJSON
BTXT
CEXE
DHTML
Explain how to use a fixture file to stub a network request in a Cypress test.
Think about loading data first, then intercepting the request.
You got /3 concepts.
    Describe the advantages of using fixtures in your Cypress tests.
    Consider how fixtures help organize and reuse test data.
    You got /4 concepts.