Test Overview
This test loads user data from a fixture file and verifies the user's name appears on the page after login.
This test loads user data from a fixture file and verifies the user's name appears on the page after login.
describe('User Login with Fixture Data', () => { beforeEach(() => { cy.fixture('user').as('userData'); }); it('logs in and shows the user name', function() { cy.visit('/login'); cy.get('#username').type(this.userData.username); cy.get('#password').type(this.userData.password); cy.get('#login-button').click(); cy.get('#welcome-message').should('contain.text', `Welcome, ${this.userData.name}`); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Load fixture file 'user.json' and alias it as 'userData' | Fixture data is available for test use | - | PASS |
| 2 | Open the login page at '/login' | Login page is displayed in the browser | - | PASS |
| 3 | Find username input and type username from fixture | Username field contains the fixture username | - | PASS |
| 4 | Find password input and type password from fixture | Password field contains the fixture password | - | PASS |
| 5 | Click the login button | Login form submitted, page navigates or updates | - | PASS |
| 6 | Check that welcome message contains the user's name from fixture | Welcome message visible with correct user name | Verify welcome message text includes fixture user name | PASS |