testing-library / testing-library/user-event
Add the interface to `userEvent.upload()` to simulate cancelling file select
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Describe the feature you'd like:
I propose the interface to simulate cancelling file select.
DOM events (for example, a change event) on input elements with type="file" doesn't include .files when users cancel to select files.
events.target.files // undefined
However, there is not the interface to simulate this on userEvent.upload().
Suggested implementation:
For example,
// it accepts `undefined` and deletes event.target.files
userEvent.upload()
Describe alternatives you've considered:
Now I am simulating with fireEvent.change() like
const input = getTestById('file-input')
input.value=""
await fileEvent.change(input)
Teachability, Documentation, Adoption, Migration Strategy:
Nothing
I'm sorry in advance for my poor english.
If I can provide more information, please let me know.
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 by locating the userEvent.upload() entry point and reading how it currently handles file selection and cancellation. Review the surrounding tests and existing API behavior, then verify that the proposed cancellation call produces the expected file-input event state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100