Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example of checking native HTML5 form validation message #1824

Open
jennifer-shehane opened this issue Jun 28, 2019 · 3 comments

Comments

2 participants
@jennifer-shehane
Copy link
Member

commented Jun 28, 2019

I'm submitting a...

[ ] Bug report
[x] Content update
[ ] Process update (build, deployment, ... )

Type of bug / changes

Add an example of how to check that a form's HTML form validation is shown when an input is invalid.

Maybe this should go in common assertions? https://docs.cypress.io/guides/references/assertions.html#Common-Assertions

Or our FAQ? I'm not sure.

it('check validation message on invalid input', () => {
  cy.get('input:invalid').should('have.length', 0)
  cy.get('[type="email"]').type('not_an_email')
  cy.get('[type="submit"]').click()
  cy.get('input:invalid').should('have.length', 1)
  cy.get('[type="email"]').then(($input) => {
    expect($input[0].validationMessage).to.eq('I expect an email!')
  })
})
@ryanpedersen42

This comment has been minimized.

Copy link

commented Jul 4, 2019

Feeling like this might be best in FAQ because that Common Assertions section is really focused on using the assertions listed before with .should(). Maybe a new "How can I check that a form's HTML form validation is shown when an input is invalid?" is the right call?

@jennifer-shehane

This comment has been minimized.

Copy link
Member Author

commented Jul 7, 2019

@ryanpedersen42 Yah, I agree!

@ryanpedersen42

This comment has been minimized.

Copy link

commented Jul 8, 2019

I'm on it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.