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

checkValidity() returns true instead of false for min length on input #1930

Open
cmttan opened this issue Jun 12, 2018 · 6 comments
Open

checkValidity() returns true instead of false for min length on input #1930

cmttan opened this issue Jun 12, 2018 · 6 comments

Comments

@cmttan
Copy link

cmttan commented Jun 12, 2018

Current behavior:

checkValidity() returns true for min length on input field.

Desired behavior:

checkValidity() should return false when min length requirement is not met.

Steps to reproduce:

demo of bug created here: https://github.com/cmttan/cyp-demo

Versions

cypress ^3.0.1
chrome 67
macOS high sierra 10.13.5 (17F77)

@jennifer-shehane
Copy link
Member

I ran the demo app in Cypress and am seeing the results below. Could you be more specific about what is wrong? Where is this checkValidity()? What it supposed to happen?

screen shot 2018-06-12 at 12 02 41 pm

@jennifer-shehane jennifer-shehane added the stage: needs information Not enough info to reproduce the issue label Jun 12, 2018
@cmttan
Copy link
Author

cmttan commented Jun 12, 2018

@jennifer-shehane the test should pass because an error should be shown if the form is not valid. For some reason, when checkValidity() is called on the form, it returns true even though it shouldn't be. This only happens through the automated test runner. If I run the app and perform the steps manually by typing in some text to the input that doesn't meet the min length requirements and click submit, an error message appears.

checkValidity() happens in app.js (line 13). when the form is submitted, checkValidity() is called on the form DOM node.

You can also view the log in the console when the form is submitted.

We should see this if the min length requirement is not met:
image

@kuceb
Copy link
Contributor

kuceb commented Jun 12, 2018

@cmttan this is a bug in Cypress.
cause:
You're using a native DOM validity check, which does not respond to simulated events, and would require native events

@cmttan
Copy link
Author

cmttan commented Jun 12, 2018

@bkucera awesome. thanks for the explanation!

@jennifer-shehane jennifer-shehane added stage: in progress type: bug and removed stage: needs information Not enough info to reproduce the issue labels Jun 12, 2018
@kuceb
Copy link
Contributor

kuceb commented Jun 14, 2018

@cmttan
After experimenting with this, this has nothing to do with bad simulated events... However, this should be fixed by Native Events, in progress!

@kuceb kuceb added this to the Sprint 16 milestone Dec 18, 2018
@kuceb kuceb self-assigned this Dec 18, 2018
@tyomasson
Copy link

tyomasson commented Sep 16, 2019

Seems, I have the same issue
react app, chrome 76, cypress 3.4.1

2019-09-16_16-42-02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants