Skip to content

Instantly share code, notes, and snippets.

@RomainGoncalves
Created May 28, 2018 19:55
Show Gist options
  • Save RomainGoncalves/e3c95bf1d4067ba5ae5bd51ab0381918 to your computer and use it in GitHub Desktop.
Save RomainGoncalves/e3c95bf1d4067ba5ae5bd51ab0381918 to your computer and use it in GitHub Desktop.
Doing multiple API request with Cypress
describe('API Requests', () => {
it('should get successful response', () => {
cy.request('GET', 'https://swapi.co/api/films/1/')
.its('body.title').should('contain', 'A New Hope');
});
it('should get successful response', () => {
cy.request('GET', 'https://swapi.co/api/films/1/')
.then(response => {
response.body.planets.forEach(planet =>
cy.request('GET', planet)
.its('body.gravity').should('contain', '1 standard'),
);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment