Test Overview
This test checks that a Cypress custom command correctly extends Cypress commands by adding a custom command. It verifies the custom command runs and produces the expected result.
This test checks that a Cypress custom command correctly extends Cypress commands by adding a custom command. It verifies the custom command runs and produces the expected result.
/// <reference types="cypress" /> // cypress/support/commands.js Cypress.Commands.add('login', (username, password) => { cy.get('#username').type(username) cy.get('#password').type(password) cy.get('#login-btn').click() }) // cypress/integration/login_spec.js describe('Login with custom command', () => { it('should login successfully using the custom login command', () => { cy.visit('https://example.cypress.io/login') cy.login('user1', 'password123') cy.url().should('include', '/dashboard') cy.get('h1').should('contain.text', 'Dashboard') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner initialized | - | PASS |
| 2 | Browser opens and navigates to 'https://example.cypress.io/login' | Login page with username, password fields and login button is visible | - | PASS |
| 3 | Custom command 'login' is called with username 'user1' and password 'password123' | Username and password fields are filled, login button is clicked | - | PASS |
| 4 | Test waits for navigation to '/dashboard' page | Dashboard page loads with heading 'Dashboard' | URL includes '/dashboard' | PASS |
| 5 | Check that the page heading contains text 'Dashboard' | Heading element visible with correct text | Heading text contains 'Dashboard' | PASS |
| 6 | Test ends successfully | Test passed, no errors | - | PASS |