0
0
Cypresstesting~5 mins

Fixture-based response mocking in Cypress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is fixture-based response mocking in Cypress?
It is a way to simulate server responses by using predefined data files called fixtures. This helps test how the app behaves with specific data without needing a real server.
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 and use it in your test.
Click to reveal answer
beginner
Why use fixture-based mocking instead of real API calls?
It makes tests faster, more reliable, and independent from the server. You control the data, so tests don’t fail because of network or server issues.
Click to reveal answer
intermediate
Which Cypress command is used to intercept a network request and respond with fixture data?
Use cy.intercept('GET', '/api/endpoint', { fixture: 'data.json' }) to mock the response with fixture data.
Click to reveal answer
beginner
What is the folder name where Cypress fixture files are stored by default?
The default folder is cypress/fixtures. Place your JSON or other data files there for easy access.
Click to reveal answer
Which command loads fixture data in Cypress?
Acy.fixture('file.json')
Bcy.load('file.json')
Ccy.mock('file.json')
Dcy.data('file.json')
Where should fixture files be placed in a Cypress project?
Acypress/plugins
Bcypress/integration
Ccypress/support
Dcypress/fixtures
What does cy.intercept() do when used with a fixture option?
AIntercepts a request and responds with fixture data
BLoads fixture data into the test context
CSaves response data to a fixture file
DRuns the test with fixture data
Why is fixture-based mocking useful in tests?
AIt slows down tests
BIt requires a live server
CIt makes tests faster and more stable
DIt hides test failures
How do you access fixture data inside a .then() callback?
Acy.load('file').then((data) => { use data })
Bcy.fixture('file').then((data) => { use data })
Ccy.mock('file').then((data) => { use data })
Dcy.data('file').then((data) => { use data })
Explain how to use fixture-based response mocking in Cypress to test an API call.
Think about intercepting requests and using saved data files.
You got /4 concepts.
    Describe the benefits of using fixture-based mocking in your tests.
    Consider what problems mocking solves.
    You got /4 concepts.