Test Overview
This test checks that a login form works correctly using a reusable pattern. It verifies that the form accepts valid input and shows a success message. Using patterns helps tests stay organized and easy to update as the app grows.
This test checks that a login form works correctly using a reusable pattern. It verifies that the form accepts valid input and shows a success message. Using patterns helps tests stay organized and easy to update as the app grows.
describe('Login Form Test', () => { beforeEach(() => { cy.visit('/login') }) it('accepts valid credentials and shows success', () => { cy.get('input[name="username"]').type('user123') cy.get('input[name="password"]').type('pass123') cy.get('button[type="submit"]').click() cy.get('.success-message').should('be.visible').and('contain.text', 'Welcome user123') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, ready to run tests | - | PASS |
| 2 | Browser opens and navigates to '/login' | Login page is loaded with username and password fields and submit button | URL is '/login' | PASS |
| 3 | Find username input and type 'user123' | Username field contains 'user123' | Input value is 'user123' | PASS |
| 4 | Find password input and type 'pass123' | Password field contains 'pass123' | Input value is 'pass123' | PASS |
| 5 | Find submit button and click | Form submitted, page processes login | - | PASS |
| 6 | Check that success message is visible and contains 'Welcome user123' | Success message displayed on page | Success message text includes 'Welcome user123' | PASS |