Understanding page events
Cypress logs every main event that takes place when the tests are running. It can detect when a URL is changing, when a button is clicked, or even when an assertion is being made. Page events capture the important events that the DOM goes through when a test is running.
To demonstrate how page events work, we will use our Todo application, as we did in the previous chapter. Following the chapter-05
directory in our GitHub repository, we will create our test file in the Cypress integration subdirectory and name it debugging.spec.js
. We will then create our test in the newly created spec file, which will navigate to the Todo application, add a todo item, and check for the page events that pop up in our Cypress test runner. The following code block will handle adding the todo item to our application:
it('can add a todo', () => { cy.get(".new-todo").type("New Todo {Enter}"); ...