Skip to content

User Registration Test Fails Due to Existing Test Data #1

@AmeliaES

Description

@AmeliaES

it('registers a new user succesfully', () => {
cy.get('[data-cy="firstName"]').type('TestUserForCypress');
cy.get('[data-cy="lastName"]').type('TestUserForCypressLastName');
cy.get('[data-cy="email"]').type('test_user123@email.com');
cy.get('[data-cy="phone"]').type('1234567890');
cy.get('[data-cy="adLine1"]').type('123 Test Address');
cy.get('[data-cy="adLine2"]').type('Test Address Line 2');
cy.get('[data-cy="country"]').type('UK');
cy.get('[data-cy="password"]').type('123456');
cy.get('[data-cy="confirmPassword"]').type('123456');
cy.get('[data-cy="submit"]').click();
// get toast and check for success message
cy.get('[data-cy="toastText"]').should(
'have.text',
'You are now registered'
);

Here the first time we run this test it creates a new test user. However, when we run it again the user is already existing in the database. The test fails as it displays a "danger" toast with error message, rather than a "success" toast.

Image

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions