/// <reference types="cypress" />
describe('Parallel Login Tests', () => {
const users = [
{ email: 'user1@example.com', password: 'Password1!' },
{ email: 'user2@example.com', password: 'Password2!' },
{ email: 'user3@example.com', password: 'Password3!' }
];
users.forEach(({ email, password }) => {
it(`logs in successfully with ${email}`, () => {
cy.visit('/login');
cy.get('[data-cy=email-input]').should('be.visible').type(email);
cy.get('[data-cy=password-input]').should('be.visible').type(password);
cy.get('[data-cy=login-button]').should('be.enabled').click();
cy.url().should('include', '/dashboard');
});
});
});This test suite defines three user credentials in an array. For each user, it runs a separate test case that visits the login page, enters the email and password, clicks the login button, and verifies the URL changes to '/dashboard'.
Selectors use data-cy attributes for stability and clarity. Assertions check visibility and enablement before interacting with elements to avoid flaky tests.
Running these tests in parallel is handled by Cypress when configured with the Cypress Dashboard or CI parallelization, so the code is written to support independent test cases that can run concurrently.