Compare The Response To A Fixture

1 · Gleb Bahmutov · March 24, 2022, 1:47 p.m.
Imagine a situation: you need to make an HTTP request from your Cypress test and compare the result to a JSON object stored in a fixture file. There are several ways of writing such test.Using cy.fixtureWe can load the fixture file when needed using cy.fixture command. We can make the request first, then load the fixture file. Since the response body variable is in the lexical scope, we can use it to form the assertion.1234567it('gives a response matching a fixture object', () => { cy.request('...