Soy nuevo en las pruebas en broma y me preguntaba si podría recibir algo de claridad sobre un asunto que tengo dificultades para entender.
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')); });Básicamente, quiero poder probar el cuadro combinado (o la declaración de selección) y probar las declaraciones dentro, pero realmente estoy luchando por entender por qué recibo los errores que recibo cuando se trata de la etapa de pelusa.
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)Debe hacer una llamada de emparejamiento después de la última espera.
it('Renders select field option', () => { render(getSelectField()); const comboBox = screen.findByRole('combobox'); expect(comboBox).toBeInDocument(); });screen.findByRole devuelve una promesa con un HTMLElement. que no manejas.
tal vez intente
screen.getByRole('combobox');