testing-library / testing-library/user-event
Can't test "file" type inputs.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Environment
@testing-library/reactversion: 14.2.1- Testing Framework and version:
react-scriptsversion: 5.0.1 - DOM Environment:
jsdomfromreact-scripts
Reproduction:
Minimal reproduction on CodeSandbox: here
What you did:
I need to assert that my api is receiving the correct files. In this minimal reproduction it might not make sense because it's like I am testing DOM, but in my real world scenario the form is more complex and in that context this test makes sense.
What happened:
when I call
expect(api).toHaveBeenCalledWith({name: "hello.txt", file: file})
I receive {name: "", file: {}}.
Basically I am unable to assert what file was passed in the function.
Thank you.
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 linked CodeSandbox reproduction and inspect how the file input interaction reaches the API call. Reproduce the {name: "", file: {}} result, then trace the user-event file-input path and its tests. Done means the selected file's name and file object are preserved so the shown assertion can pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react, typescript
- 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