Skip to content

Instantly share code, notes, and snippets.

@bmitchinson
Created March 25, 2020 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmitchinson/2c38e47b0dece42e434962e760d6e49e to your computer and use it in GitHub Desktop.
Save bmitchinson/2c38e47b0dece42e434962e760d6e49e to your computer and use it in GitHub Desktop.
import { baseURL } from '../../../cypress';
describe('API Testing with Cypress', () => {
beforeEach(() => {
cy.request(${baseURL}/25).as('pikachu');
});
it('Validate the header', () => {
cy.get('@pikachu')
.its('headers')
.its('content-type')
.should('include', 'application/json; charset=utf-8');
});
it('Validate the status code', () => {
cy.get('@pikachu')
.its('status')
.should('equal', 200);
});
it('Validate the pokemon\'s name', () => {
cy.get('@pikachu')
.its('body')
.should('include', { name: 'pikachu' });
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment