mercredi 13 mai 2020

Is it possible to define a custom fireEvent in React Testing Library?

So I know it is possible to create custom queries in React Testing Library by using the buildQuries helper function, but Is there a way to define some helper to for example get an input by its label and then change its value?

I tried to create a custom query and inside it call fireEvent, but couldn't make it work.

The function I need will look something like this:

changeInputWithLabel(labelText, targetText): {
   fireEvent.change(getByLabelText(labelText), {target: {value: targetText}});
}

Aucun commentaire:

Enregistrer un commentaire