-
Notifications
You must be signed in to change notification settings - Fork 469
Add createEvent that returns the created Event #258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me other than one comment
package.json
Outdated
@@ -30,7 +30,8 @@ | |||
"test:update": "npm test -- --updateSnapshot --coverage", | |||
"validate": "kcd-scripts validate", | |||
"setup": "npm install && npm run validate -s", | |||
"dtslint": "dtslint typings" | |||
"dtslint": "dtslint typings", | |||
"precommit": "kcd-scripts pre-commit" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you revert these changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humpf sorry. I was trying to see what was wrong with my commit on typescript definitions...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent 💯
Could you make a pull request to the docs site to add documentation? |
@allcontributors[bot] please add @dbismut for code |
I've put up a pull request to add @dbismut! 🎉 |
🎉 This PR is included in version 4.1.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Yes I will PR the docs (although my English might be shaky)! Is it necessary to add createEvent as an export to react-testing-library? |
react-testing-library re-experts everything from dom-testing-library so we're good there 👍 |
What:
Exposes a utility to create events that can be thrown by
fireEvent
. This is useful in order to have access to the source event attributes see #257Why:
Some components might rely on event attributes created when the event object is created (i.e.
new Event({...eventAttributes})
).How:
As suggested by @kentcdodds in #257:
However since the event constructor depends on
window
which itself depends on the node,createEvent
also requires the node to be passed as an argument (not very elegant I admit).Checklist:
fireEvent
now usescreateEvent
I believe successful tests onfireEvent
covercreateEvent
Pre-commit hook threw an error on Typescript definitions but I'm really not sure what's wrong, so I committed with the
--no-verify
flag.