Test Overview
This test checks that the test name clearly describes what the test does. It verifies that the test name follows good naming conventions for easy understanding.
This test checks that the test name clearly describes what the test does. It verifies that the test name follows good naming conventions for easy understanding.
describe('Login Page Tests', () => { it('should display error message when login fails with invalid credentials', () => { cy.visit('/login'); cy.get('#username').type('wrongUser'); cy.get('#password').type('wrongPass'); cy.get('#login-button').click(); cy.get('.error-message').should('be.visible').and('contain', 'Invalid username or password'); }); });
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts with the name 'should display error message when login fails with invalid credentials' | Test framework ready to run the test | — | PASS |
| 2 | Browser opens and navigates to '/login' page | Login page is loaded in the browser | — | PASS |
| 3 | Finds username input field with id '#username' and types 'wrongUser' | Username field contains 'wrongUser' | — | PASS |
| 4 | Finds password input field with id '#password' and types 'wrongPass' | Password field contains 'wrongPass' | — | PASS |
| 5 | Finds login button with id '#login-button' and clicks it | Login form submitted | — | PASS |
| 6 | Finds element with class '.error-message' and checks it is visible and contains text 'Invalid username or password' | Error message displayed on the page | Error message is visible and text matches expected | PASS |
it function with a string name and a callback function to define a test case.it syntax = it('should load the homepage', () => { /* test code */ }) [OK]it('name', () => {}) is correct syntax [OK]describe('Login Page', () => {
it('accepts valid credentials', () => {
// test steps
})
})describe block name and the it test name separated by a space for the full test name.describe is 'Login Page' and the it is 'accepts valid credentials', so combined they form 'Login Page accepts valid credentials'.describe('User Login')
it('should login successfully', () => {
// test code
})describe block must have curly braces {} to wrap its content, but here it is missing.describe('User Login') to include the it block inside it.Pass the test and this pattern moves unknown