Skip to content

Instantly share code, notes, and snippets.

@RomainGoncalves
Created May 28, 2018 21:01
Show Gist options
  • Save RomainGoncalves/522dd15c4e94a075b6b470f2881b67ef to your computer and use it in GitHub Desktop.
Save RomainGoncalves/522dd15c4e94a075b6b470f2881b67ef to your computer and use it in GitHub Desktop.
// cypress/support/commands.js
Cypress.Commands.add('fetchFilm', movieIndex => {
cy.request('GET', `https://swapi.co/api/films/${movieIndex}/`);
});
// integration/api/fetchMovies.js
describe('API Requests', () => {
it('should get successful response', () => {
cy.fetchFilm(1).as('firstMovie');
cy.get('@firstMovie').its('body.title').should('contain', 'A New Hope');
cy.get('@firstMovie').its('body.director').should('contain', 'George Lucas');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment