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

1.8K
Vistas
Jest The given element does not have a value setter

I'm currently writing Jest unit tests for two separate Material UI components that I am using: TextField and Menu.

In short, my component looks something like this:

MyComponent.js

<h3>Hello</h3>

<Textfield 
    name="myTextField"
    onChange={//onChangeMethod}
    value={//valueOfAState}
    inputProps={{ "data-testid": "textfield-input" }}
/>


<Menu
    open={true}
    data-testid="case-menu-select"
>
    <MenuItem>
        <ListItemText
            data-testid="list-item-select-option1"
            key="1"
        >
            First Item
        </ListItemText>
    </MenuItem>
    <MenuItem>
        <ListItemText
            data-testid="list-item-select-option2"
            key="2"
        >
            Second Item
        </ListItemText>
    </MenuItem>
</Menu>

Essentially, I'm trying to write a test that will select the second option from the Menu. I've written a test that looks something like this:

test("test menu select options", async () => {
    const { getByTestId } = Render(<MyComponent />)

    const text = getByTestId("textfield-input")
    fireEvent.change(text, { target: { value : "whatever text" } }) //works fine

    const menuSelect = getByTestId("case-menu-select")
    // select second option from the menu
    fireEvent.change(menuSelect, { target: { value: 2 } }) //fails
})

I'm getting an error at the line that fails:

The given element does not have a value setter

I've included the TextField example to showcase that it works. I've also tried to set an inputProps to the Menu component, but that doesn't exist.

How can I select an option from a Menu component?

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