Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

1.8K
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!