Skip to content

Instantly share code, notes, and snippets.

@yagudaev
Created January 21, 2019 20:33
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/8b13571fafcc5fef1c8303ccff36018d to your computer and use it in GitHub Desktop.
Save yagudaev/8b13571fafcc5fef1c8303ccff36018d to your computer and use it in GitHub Desktop.
Testing Your Frontend with Cypress.io Framework
// This is what you want...
describe('Shopping Cart', () => {
before(() => {
cy.login('michael@example.com', 'password')
})
beforeEach(() => {
resetShoppingCart()
})
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'))
})
})
const resetShoppingCart = () => {
cy.visit('/')
cy.contains('Show Cart').click()
cy.contains('Reset Cart').click()
}
it('A Pro User logs in and sees a thank you message for the first time', () => {
loginWith('new-pro@example.com', 'passsword')
expect(cy.contains('Thank you for supporting us!')).toBeTruthy
})
it('A Pro User logs in and sees and sees a welcome message', () => {
loginWith('old-pro@example.com', 'passsword')
expect(cy.contains('Welcome back John')).toBeTruthy
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment