jeudi 25 mars 2021

Click on all elements found - React Testing Library

I'm trying to click on all elements found with the same data-testid, but what i've tried doesn't worked.

get elements() {
  return this.screen.findAllByTestId("test");
}

async clickAllElements() {
  const elements = await this.elements;
  elements.forEach(element => {
    userEvent.click(element);
  });
}

If i log the "elements" variable it shows an array with 2 elements, but it doesn't click on them.

Aucun commentaire:

Enregistrer un commentaire