Skip to content

Instantly share code, notes, and snippets.

@ronderksen
Last active February 8, 2019 09:01
Show Gist options
  • Save ronderksen/0219f3ab06f9febaf3bd951f76c58576 to your computer and use it in GitHub Desktop.
Save ronderksen/0219f3ab06f9febaf3bd951f76c58576 to your computer and use it in GitHub Desktop.
describe('Page: list of Star Wars characters', () => {
const characters = [
{
name: 'Chewbacca',
species: 'Wookie',
},
{
name: 'Luke Skywalker',
species: 'Human',
}
];
beforeEach(() => {
cy.mockGraphQL((operationName) => {
switch (operationName) {
case 'GET_CHARACTER_LIST':
return {
test(variables) {
expect(variables.faction).toEqual('Rebels');
},
mockResult: {
data: {
getCharacterList: characters
}
}
};
default:
return {};
}
});
});
it('should show a list of Rebel characters', () => {
cy.visit('/characters/rebels')
.get('li.character')
.each((li, idx) => cy
.wrap(li)
.find('span.name')
.should('contain', characters[idx].name)
.find('span.species')
.should('contain', characters[idx].species)
);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment