Skip to content

Commit

Permalink
completed chapter 6; includes examples for 'Enter' button, mouseover,…
Browse files Browse the repository at this point in the history
… force-click
  • Loading branch information
leobooth committed Jul 16, 2024
1 parent 9916dca commit dc244e5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
3 changes: 2 additions & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ module.exports = defineConfig({
setupNodeEvents(on, config) {
// implement node event listeners here
},
// baseUrl: 'http://localhost:3000',
// baseUrl: 'https://todomvc.com/examples/react/dist/',
// viewportHeight: 550,
// viewportWidth: 660
experimentalStudio: true
},
});
23 changes: 20 additions & 3 deletions cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
it('my first test', () => {
cy.visit('https://cypress.io')
});
function addTodo(todoText) {
let todo1 = cy.get("[data-testid='text-input']");
todo1.click();
todo1.type(todoText);
todo1.type("{enter}");
}

function removeTodo(todoText) {
let todoItem = cy.get("[data-testid='todo-item-label']").contains(todoText);
todoItem.trigger('mouseover');
let todoItemRemoveButton = cy.get("[data-testid='todo-item-button']");
todoItemRemoveButton.click({force: true});
}

it('add and remove a single todo item', () => {
cy.visit('https://todomvc.com/examples/react/dist/');
addTodo('todo1');
removeTodo('todo1');
});

17 changes: 17 additions & 0 deletions cypress/support/quickstart.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Terminal commands
=================

node -v
* check what version of Node is installed

npm init
* initialize a Node project in the current folder

npm init -y
* initialize a Node project and say accept all configuration defaults

npm install cypress
* install Cypress and its dependencies into the current Node project

npx cypress open
* open Cypress in UI mode

0 comments on commit dc244e5

Please sign in to comment.