Skip to content

Instantly share code, notes, and snippets.

@tarasowski
Created March 6, 2024 12:01
Show Gist options
  • Save tarasowski/c226683878589d5f37bc7b4e59fe8357 to your computer and use it in GitHub Desktop.
Save tarasowski/c226683878589d5f37bc7b4e59fe8357 to your computer and use it in GitHub Desktop.
describe('Newsletter Subscribe Form', () => {
beforeEach(() => {
cy.visit('http://localhost:3000')
})
it('allows users to subscribe to the email list', () => {
const email = "dimitri@techstarter.de"
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 = "john@example.com"
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