Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
RTL getByRole working weirdly. Why does It require extra characters to work properly?

I am trying to get an element with RTL ( React testing library ) getByRole method.

My observation:

It works when I add characters ( 12+ ).

Ex:

// Form

<Col xs={24} md={6}>
  <StyledLabel htmlFor="full-name-member">
    <LargeFont>Member Name_</LargeFont> // this line
  </StyledLabel>
  <TextBox
    name="fullName"
    placeholder="Full Name"
    required={false}
    rule="text"
    maxLength={100}
    id="full-name-member"
  />
</Col>;


screen.getByRole('textbox', { name: 'Member Name' });

Notice the extra _ underscore. It works when I add one more character than actually required.

I have counted the length for it. It's 12+ for working properly where If I remove an extra character, it doesn't work as it should.

Ex:

// Form

<Col xs={24} md={6}>
  <StyledLabel htmlFor="full-name-member">
    <LargeFont>Member Name</LargeFont> // this line
  </StyledLabel>
  <TextBox
    name="fullName"
    placeholder="Full Name"
    required={false}
    rule="text"
    maxLength={100}
    id="full-name-member"
  />
</Col>;


screen.getByRole('textbox', { name: 'Member Name' });

Explanation:

  • Styled is just a prefix for styled-component wrapped components.
  • Col & TextBox components belongs from ant-design.
  • LargeFont is a wrapper around div element with fixed css.

What could be the reason for this weird behaviour?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda