How to call onPress handler in RTL when button is disabled?

Viewed 59

I have a slightly weird requirement whereby I need to disable a button if a user has not typed input but still actually have this button click and show an error message if they still click it.

act(() => {
  fireEvent.press(getByText('Continue'))
})

this actually works in the code but the tests are failing. I wonder that if RTL/Jest see it's disabled and the handler just isn't called? (even though it's being called fine in the code)

Was wondering if there was anything I can do to get jest to still call this despite it being disabled? or if my only option is to show disabled in a "styled" way?

0 Answers
Related