Skip to content

Instantly share code, notes, and snippets.

@yagudaev
Last active February 25, 2019 22:39
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 yagudaev/f6803e5b806c9e5b16dba34ad975f65f to your computer and use it in GitHub Desktop.
Save yagudaev/f6803e5b806c9e5b16dba34ad975f65f to your computer and use it in GitHub Desktop.
Testing Your Frontend with Cypress.io Framework
// cypress/integration/login.spec.js
describe('login', () => {
beforeEach(() => {
visitLoginPage()
})
it('A User logs in and sees a welcome message', () => {
loginWith('michael@example.com', 'passsword')
expect(cy.contains('Welcome back Michael')).to.exist
})
it('A User logs off and sees a goodbye message', () => {
loginWith('michael@example.com', 'password')
logout()
expect(cy.contains('Goodbye! See you soon!'))
})
})
const visitLoginPage = () => {
cy.visit('http://localhost:3000')
}
const loginWith = (email, password) => {
cy.get('[name="email"]').type(email)
cy.get('[name="password"]').type(password)
cy.get('button').click()
}
const logout = () => {
cy.get('button').click()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment