Replies: 1 comment
-
|
Yeah, this is a classic race condition often seen in fast automation environments like Cypress. The reason is that When you see First, make sure you are actually destructuring // This destructuring is required for subscription
const { formState: { isValid, errors } } = useForm({
mode: 'onChange'
});For Cypress specifically, stop checking the // ❌ Avoid checking raw state
// expect(formState.isValid).to.be.true;
// ✅ Assert on the UI
cy.get('input[name="email"]').type('test@example.com');
cy.get('button[type="submit"]').should('not.be.disabled');If you really need the state, you can wait for the validation to settle by checking |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Just need to know - under what conditions after validation has succeeded and there are no errors, can
isValidremainfalse?This problem (if it's a problem) occurs only when filling out a form with Cypress, but not manually. This makes me suspect a race condition. But why can I see
isValidatinggoing fromtrueand back tofalse, produce no errors, and keepisValidatfalse? How? Why?Beta Was this translation helpful? Give feedback.
All reactions