[material-ui][Autocomplete] "Unable to find the input element" error while snapshot testing with react-test-renderer
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 99.1k
- Forks
- 32.5k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 106
Description
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Steps to reproduce 🕹
Link to live example: https://codesandbox.io/p/sandbox/reverent-worker-y7dtfw
Steps:
- Use Autocomplete component with renderInput prop specified as follows:
renderInput={(params) => (
<Tooltip title="Tooltip">
<TextField {...params} />
</Tooltip>
)}
- Snapshot test such Autocomplete with "react-test-renderer": "18.2.0"
Current behavior 😯
Snapshot is created properly.
There is following error while creating snapshot:
"MUI: Unable to find the input element. It was resolved to null while an HTMLInputElement was expected.
Instead, Autocomplete expects an input element.
Make sure you have customized the input component correctly."
Expected behavior 🤔
Snapshot is created properly.
There are no errors while creating snapshot.
Context 🔦
I wanted to customize Autocomplete to show the tooltip for the input/TextFileld value whenever the value is too long and ends with ellipsis. I find it usefull for the users to see the full label in the tooltip, in case it is trucated in the input.
Your environment 🌎
npx @mui/envinfo
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
Binaries:
Node: 20.4.0 - ~/.nvm/versions/node/v20.4.0/bin/node
Yarn: 1.22.4 - ~/.nvm/versions/node/v20.4.0/bin/yarn
npm: 9.7.2 - ~/.nvm/versions/node/v20.4.0/bin/npm
Browsers:
Chrome: session.
Chrome version used: Version 119.0.6045.200 (Official Build) (64-bit)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Autocomplete reproduction in the linked CodeSandbox and run the snapshot case using react-test-renderer 18.2.0. Trace the input-element warning during snapshot creation; done means the snapshot is still created and no error is emitted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100