Skip to content

Instantly share code, notes, and snippets.

@nottyo
Created July 6, 2019 09:08
Show Gist options
  • Save nottyo/8acdd1711af3b1b0258b43f9f81cce99 to your computer and use it in GitHub Desktop.
Save nottyo/8acdd1711af3b1b0258b43f9f81cce99 to your computer and use it in GitHub Desktop.
Todo E2E Test
/// <reference types="Cypress" />
describe('Add Todo', () => {
beforeEach(() => {
cy.visit(Cypress.config('baseUrl'))
})
it('should be able to add new todo', () => {
const firstTodo = 'Writing a blog'
const secondTodo = 'Running'
cy.get('[data-at="new-todo"]').type(`${firstTodo}{enter}`)
.type(`${secondTodo}{enter}`)
cy.get('[data-at="todoText"]').eq(0).should('contain', firstTodo)
cy.get('[data-at="todoText"]').eq(1).should('contain', secondTodo)
cy.get('[data-at="removeTodoBtn"]').should('have.length', 2)
})
it('should be able to delete todo', () => {
const todoText = 'To be deleleted'
cy.get('[data-at="new-todo"]').type(`${todoText}{enter}`)
cy.get('[data-at="removeTodoBtn"]').click()
cy.get('[data-at="noTodo"]').should('contain', 'No Anything Todo')
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment