Created
December 31, 2019 14:07
-
-
Save msalahz/870f4ff96d28716b8af272eb459e58f1 to your computer and use it in GitHub Desktop.
e2e test
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
/// <reference types="cypress" /> | |
// constants | |
const TODO_ITEM_ONE = "Learn some Vue JS"; | |
let TODO_ITEM_TWO = "Create tests with cypress.io"; | |
let TODO_ITEM_THREE = "Apply applitools visual testing"; | |
describe("Todo App Test Suite", () => { | |
// before each test, make sure to visit the home page of the app | |
beforeEach(() => { | |
cy.visit("/"); // "baseUrl" is defined in cypress.json file | |
}); | |
context("Add todos", () => { | |
it.only("should allow me to add todo items", () => { | |
// create one todo item | |
cy.get("[data-cy=todo-input]") // grab the input textbox | |
.type(TODO_ITEM_ONE) // type the title of the todo | |
.type("{enter}"); // press enter | |
// verify the item was added | |
cy.get("[data-cy=todo-list] li") | |
.eq(0) // first li | |
.find("label") | |
.should("contain", TODO_ITEM_ONE); | |
// create one todo item | |
cy.get("[data-cy=todo-input]") | |
.type(TODO_ITEM_TWO) | |
.type("{enter}"); | |
// verify the item was added | |
cy.get("[data-cy=todo-list] li") | |
.eq(1) // second li | |
.find("label") | |
.should("contain", TODO_ITEM_TWO); | |
// create one todo item | |
cy.get("[data-cy=todo-input]") | |
.type(TODO_ITEM_THREE) | |
.type("{enter}"); | |
// verify the item was added | |
cy.get("[data-cy=todo-list] li") | |
.eq(2) // third li | |
.find("label") | |
.should("contain", TODO_ITEM_THREE); | |
// verify the count is correct | |
cy.get("[data-cy=todo-count]").contains("3"); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment