Skip to content

Instantly share code, notes, and snippets.

@joelgriffith
Created July 11, 2017 17:24
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 joelgriffith/8dd0d690e5683e437ed0061ee9994458 to your computer and use it in GitHub Desktop.
Save joelgriffith/8dd0d690e5683e437ed0061ee9994458 to your computer and use it in GitHub Desktop.
Composing a user interaction with further assertions
// :missingUsername visits a page and immediately clicks submit
// without entering the user's name. It returns the chrome instance
// so you can invoke further actions or assertions!
const missingUsername = (chrome) =>
chrome.goto('http://localhost:3000/')
.then(() => chrome.click('[data-test="submit"]'));
// Consume the prior action and assert further behavior
it('should allow users to dismiss errors', () => {
return missingUsername(chrome)
.then(() => chrome.click('[data-test="error"] button'))
.then(() => chrome.exists('[data-test="error"]'))
.then((errorExists) => expect(errorExists).toEqual(false));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment