|
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.

CodeSpace-Portfolio/cypress/e2e/register.cy.js
Lines 19 to 34 in 05c8779
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.