Skip to content

Instantly share code, notes, and snippets.

@RomainGoncalves
Created May 28, 2018 21:17
Show Gist options
  • Save RomainGoncalves/bd48bc85ab788aaa60a596ea11e5552b to your computer and use it in GitHub Desktop.
Save RomainGoncalves/bd48bc85ab788aaa60a596ea11e5552b to your computer and use it in GitHub Desktop.
describe('Fetch Movies', () => {
it('should contain all the expected attributes', () => {
cy.fetchFilm(1).as('firstMovie');
const toTest = [
{ target: 'body.title', value: 'A New Hope', should: 'contain' },
{ target: 'body.director', value: 'George Lucas', should: 'contain' },
// Check for at least 1 producer
{ target: 'body.producer', value: 'Rick McCallum', should: 'contain' },
// We can also check for any assertion that Mocha/Chai provides
{ target: 'body.planets', value: 'array', should: 'to.be.a' },
{ target: 'body.planets', value: 3, should: 'length' },
];
toTest.forEach(test => cy.get('@firstMovie').its(test.target).should(test.should, test.value));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment