Skip to content

Commit

Permalink
completed chapters 9 and 10; includes examples for headless mode
Browse files Browse the repository at this point in the history
  • Loading branch information
leobooth committed Jul 18, 2024
1 parent aaa7086 commit 0ce55c6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 16 additions & 1 deletion cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ it('completed todo item label has text decoration \'line-through\'', () => {
clearCompletedTodos();
});

it.only('changes checkbox search timeout to 6 seconds', () => {
// to change timeouts globally, set 'defaultCommandTimeout' key-value in cypress.config.js
it('changes checkbox search timeout locally to 6 seconds', () => {
cy.visit('https://todomvc.com/examples/react/dist/');
addTodo('todo1');
completeTodo('todo1');
Expand All @@ -98,4 +99,18 @@ it.only('changes checkbox search timeout to 6 seconds', () => {
todoCheckbox.should('be.checked');

clearCompletedTodos();
});

// create test that will always fail to demonstrate headless test results
it('this test should always fail (input toggle unchecked)', () => {
cy.visit('https://todomvc.com/examples/react/dist/');
addTodo('todo1');


let todoCheckboxes = cy.get("[data-testid='todo-item-label']", {timeout: 6000});
let todoCheckbox = todoCheckboxes.contains('todo1')
.siblings("[data-testid='todo-item-toggle']");
todoCheckbox.should('be.checked');

removeTodo('todo1');
});
12 changes: 11 additions & 1 deletion cypress/support/quickstart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ npm install cypress
* install Cypress and its dependencies into the current Node project

npx cypress open
* open Cypress in UI mode
* open Cypress in UI mode

npx cypress run
* run Cypress in headless mode

command line options:
--browser [name of browser]
* use a specific browser

--headed
* use with Cypress in 'run' mode to open a browser and observe tests

0 comments on commit 0ce55c6

Please sign in to comment.