testing-library / testing-library/user-event
Export createDataTransfer util function
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.3k
- Forks
- 258
- PR merge metrics
- No merged PRs in 30d
Description
Problem description
When testing paste functionality, it would be really helpful to be able to use the internal createDataTransfer functionality.
I've previously created a simple mock of the DataTransfer object but this can cause frustrating test failures when it doesn't behave in exactly the same way that user-event expects it to, e.g. returning the text/plain data when getData('text') is called.
Suggested solution
Since user-event's paste functionality seems to expect that the mocked DataTransfer object behaves as the internally mocked version does, it would be really helpful to expose createDataTransfer to allow the user to create an instance of that version.
Additional context
No response
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 internal createDataTransfer function and the package's public export entry point, then inspect the existing paste-related tests. The work is complete when consumers can import createDataTransfer and use it to create the same DataTransfer mock expected by paste functionality, with the relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100