Created
March 6, 2024 12:01
-
-
Save tarasowski/c226683878589d5f37bc7b4e59fe8357 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('Newsletter Subscribe Form', () => { | |
beforeEach(() => { | |
cy.visit('http://localhost:3000') | |
}) | |
it('allows users to subscribe to the email list', () => { | |
const email = "[email protected]" | |
cy.getByData("email-input").type(email) | |
cy.getByData("submit-button").click() | |
cy.getByData("success-message").contains(email) | |
}) | |
it("does not allows an invalid email address", () => { | |
const email = "dimitri" | |
cy.getByData("email-input").type(email) | |
cy.getByData("submit-button").click() | |
cy.getByData("success-message").should("not.exist") | |
}) | |
it("does not allow re-subscribing if the user is already subscribed", () => { | |
const email = "[email protected]" | |
cy.getByData("email-input").type(email) | |
cy.getByData("submit-button").click() | |
cy.getByData("server-error-message").should("exist") | |
}) | |
afterEach(() => { | |
cy.log('Test finished') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment