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

Cypress can't check any radio buttons when required using React-Hook-Form #30302

Open
junerockwell opened this issue Sep 26, 2024 · 0 comments
Open
Labels
E2E Issue related to end-to-end testing stage: needs investigating Someone from Cypress needs to look at this type: bug

Comments

@junerockwell
Copy link

junerockwell commented Sep 26, 2024

Current behavior

Cypress can't check any radio buttons when required using React-Hook-Form

Brief Description

I'm using React-Hook-Form to validate and submit my form. When I run the e2e testing, Cypress can't check any of the radio buttons except for the last one if these radio buttons are required. If they're registered as a React-Hook-Form field but are not required, then Cypress can check any of them.

Steps

  1. Run the e2e test as is with the current files in the branch (if you pull down the branch) npm run cy:open.
  2. Run the modalForm.spec.ts.
  3. See how the first radio button (.check() value "regular") is not checked by Cypress.
  4. See how the second radio button, if you change the .check() value from "regular" to "lime" in the modalForm.spec.ts, is not checked by Cypress.
  5. But if you change the .check() value from either "regular" or "lime" to "blueberry" in the modalForm.spec.ts, then Cypress can check it.
  6. In the ModalForm.tsx, take out the { required: true } from each of the radio buttons in the form. Then change the value to "regular" in the modalForm.spec.ts. Run npm run cy:open. You can see that the first radio button is checked by Cypress.

Video Demo

https://www.loom.com/share/370ebac07a8c4451bfd8109db429b4a1

Desired behavior

Cypress should be able to check any radio button no matter which form framework validation should work. In this case, I'm using React-Hook-Form. And specifically, they won't check if they're required in React-Hook-Form.

Test code to reproduce

Links to files:

The Branch

https://github.com/junerockwell/github-actions-nextjs-cypress-vercel/tree/cypress-reacthookform-radio-issue

Cypress Version

13.14.2

Node version

21.7.3

Operating System

macOS 12.3.1

Debug Logs

No response

Other

  • NextJS v14.2.9
  • DayJS v1.11.13
  • Tailwind v3.4.1
  • React v18
  • React-Hook-Form v7.53.0
  • TypeScript v5
@jennifer-shehane jennifer-shehane added type: bug stage: needs investigating Someone from Cypress needs to look at this E2E Issue related to end-to-end testing labels Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E2E Issue related to end-to-end testing stage: needs investigating Someone from Cypress needs to look at this type: bug
Projects
None yet
Development

No branches or pull requests

2 participants