Last active
February 25, 2019 22:40
-
-
Save yagudaev/ef9084290085f4310fa59bcd86d52f79 to your computer and use it in GitHub Desktop.
Testing Your Frontend with Cypress.io Framework
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cypress/integration/login.spec.js | |
describe('login', () => { | |
beforeEach(() => { | |
visitLoginPage() | |
}) | |
it('A User logs in and sees a welcome message', () => { | |
loginWith('[email protected]', 'passsword') | |
expect(cy.contains('Welcome back Michael')).to.exist | |
}) | |
it('A User logs off and sees a goodbye message', () => { | |
loginWith('[email protected]', '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