Skip to content

Instantly share code, notes, and snippets.

@yagudaev
Created January 21, 2019 20:30
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/21baf902c132a022e8f43394708f843c to your computer and use it in GitHub Desktop.
Save yagudaev/21baf902c132a022e8f43394708f843c to your computer and use it in GitHub Desktop.
Testing Your Frontend with Cypress.io Framework
// not great...
describe('Shopping Cart', () => {
before(() => {
cy.login('michael@example.com', 'password')
})
it('add item to cart', () => {
cy.visit('/products/fidget-spinner-1')
cy.contains('Add To Cart').click()
cy.contains('Show Cart').click()
expect(cy.contains('Shopping Cart'))
expect(cy.contains('Fidget Spinner'))
expect(cy.contains('$10.00'))
})
after(() => {
// not guranteed to be called if you quit before test completes (e.g auto reload)
restShoppingCart()
})
})
const resetShoppingCart = () => {
cy.visit('/')
cy.contains('Show Cart').click()
cy.contains('Reset Cart').click()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment