Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
react-select-event doesn't trigger the onChange function to set the value during testing

It's been a couple of days that I'm struggling with a test I'm trying to write and thought this would be a good place to ask for some tips. I'm trying to fill a form that uses react-select dropdowns, and these forms are inside a map that renders 4 of them. However when trying to run the code below on the selectors of each form in a loop, after the first iteration which runs fine, the input element found in the form to perform the onChange doesn't have the onChange handler and doesn't trigger the change function to select the option I need. The package I am using for the selection is react-select-event as per the documentation here. I am still a beginner with react-testing-library and testing in general so it's quite probable that I missed something. Any tips or ideas are welcome! Thank you 🙂

const selectOptionAndAssertValue = async (indicator, field, element, option, inputForm) => {
  await selectEvent.select(element, option.label, {
    container: document.body,
  });

  await waitFor(
    async () => {
      expect(inputForm).toHaveFormValues({
        [${indicator.short_alias}-${field}]: option.value,
      });
    },
    {
      onTimeout: error => console.log(error),
    }
  );
};

Note: to find the inputForm, I am using findByLabelText and it does find the element.


EDIT: Issue replicated in this repo https://github.com/ildaballiu/select-testing-demo


about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The issue was solved by changing the container to

 container: () => document.body.querySelector('[class$=-menu]')
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda