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

158
Vistas
Jest test functions on select statements in React JS

I am new to testing in jest and I was wondering if I could receive some clarity on a matter I am having difficulty understanding.

const getSelectField = () =>
  <SelectField
    name={name}
    id={id}
    aria-label="test"
    value={value}
    options={options} />;

describe('Select Field', () => {
  it('Renders SelectField', () => {
    const selectField = render(getSelectField());
    expect(selectField).toMatchSnapshot();
  });

  it('Renders select field option', () => {
    render(getSelectField());
    expect(screen.findByRole('combobox'));
  });

I want to essentially be able to test the combobox(or select statement) and test the statements within but I really am just struggling to understand why I'm getting the errors I'm getting when it comes to the linting stage.

  29:5   error  Expect must have a corresponding matcher call             jest/valid-expect
  29:19  error  promise returned from `findByRole` query must be handled  testing-library/await-async-query

✖ 2 problems (2 errors, 0 warnings)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You need to make a matcher call after the last expect.

it('Renders select field option', () => {
    render(getSelectField());
    const comboBox = screen.findByRole('combobox');
    expect(comboBox).toBeInDocument();
  });

The screen.findByRole return a promise with a HTMLElement. which you dont handle.

Maybe try

screen.getByRole('combobox');
about 4 years ago · Juan Pablo Isaza Denunciar
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