Test Overview
This test triggers a custom event on a button and verifies that the event handler updates the page content as expected.
This test triggers a custom event on a button and verifies that the event handler updates the page content as expected.
describe('Custom event trigger test', () => { it('should trigger a custom event and update text', () => { cy.visit('https://example.cypress.io/commands/actions') cy.get('#action-canvas') .trigger('myCustomEvent', { detail: { message: 'Hello Cypress!' } }) cy.get('#custom-event-output').should('contain.text', 'Hello Cypress!') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner is ready | - | PASS |
| 2 | Browser opens and navigates to 'https://example.cypress.io/commands/actions' | Page with various action examples is loaded | Page loaded successfully | PASS |
| 3 | Find element with id 'action-canvas' | Element '#action-canvas' is visible on the page | Element exists and is visible | PASS |
| 4 | Trigger custom event 'myCustomEvent' on '#action-canvas' with detail { message: 'Hello Cypress!' } | Custom event dispatched on the element | Event handler updates '#custom-event-output' text | PASS |
| 5 | Find element with id 'custom-event-output' and check text contains 'Hello Cypress!' | Element '#custom-event-output' shows updated text | Text contains 'Hello Cypress!' | PASS |