Test Overview
This test adds a custom Cypress command with TypeScript support and verifies it works correctly by checking the page title.
This test adds a custom Cypress command with TypeScript support and verifies it works correctly by checking the page title.
/// <reference types="cypress" /> declare namespace Cypress { interface Chainable { login(username: string, password: string): Chainable<void> } } Cypress.Commands.add('login', (username, password) => { cy.get('#username').type(username) cy.get('#password').type(password) cy.get('#login-btn').click() }) describe('Custom Command with TypeScript', () => { it('should login using custom command and verify title', () => { cy.visit('https://example.com/login') cy.login('user1', 'pass123') cy.title().should('include', 'Dashboard') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Cypress test runner initialized with TypeScript support | - | PASS |
| 2 | Browser opens and navigates to https://example.com/login | Login page is loaded with username, password fields and login button | - | PASS |
| 3 | Finds element #username and types 'user1' | Username input field contains 'user1' | - | PASS |
| 4 | Finds element #password and types 'pass123' | Password input field contains 'pass123' | - | PASS |
| 5 | Finds element #login-btn and clicks it | Login form submitted, page navigates to dashboard | - | PASS |
| 6 | Checks page title includes 'Dashboard' | Page title is 'User Dashboard - Example' | Title includes 'Dashboard' | PASS |