#Strange issue testing Accordion component with Jest & React Testing Library

3 messages · Page 1 of 1 (latest)

crystal ferry
#

I can't seem to get RTL to wait for the accordion to open to then be able to click on an item inside.

    // Accordion.Control
    const ageButton = screen.getByRole('button', {
      name: /All ages/,
    });
    userEvent.click(ageButton);
    
    // Button inside Accordion.Panel
    const option = await screen.findByRole('option', {
      name: /6-12 months/,
    });

Unable to find role="option"

But if i change the transitionDuration on the Accordion to 0, it works? Anyone had any similar issues?

versed vault
crystal ferry
#

I've resolved with this workaround

const option = await screen.findByRole('option', {
  name: /6-12 months/,
  hidden: true,
});