Verify login functionality with proper test naming
Preconditions (1)
✅ Expected Result: User is successfully logged in and redirected to the dashboard page with a welcome message displayed
describe('Login Functionality', () => { it('should log in successfully with valid credentials and redirect to dashboard', () => { cy.visit('/login'); cy.get('#email').type('user@example.com'); cy.get('#password').type('Password123'); cy.get('#login-button').click(); cy.url().should('include', '/dashboard'); cy.contains('Welcome').should('be.visible'); }); });
The describe block groups tests related to login functionality.
The it block has a clear, descriptive name explaining what the test does: it logs in with valid credentials and expects a redirect to the dashboard.
Selectors use IDs for clarity and reliability.
Assertions check the URL and presence of a welcome message to confirm successful login.
This naming style helps anyone reading the test understand its purpose immediately.
Now add data-driven testing with 3 different sets of valid login credentials using Cypress 'it.each' or similar approach
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