Skip to content
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

test(fireEvent): Add expected behavior for blur/focus in React #757

Merged
merged 1 commit into from
Aug 4, 2020

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Aug 4, 2020

What:

Add expected behavior for blur and focus bubbling in React. This is different than native DOM events where blur and focus do not bubble

Why:

Got messaged by core members that they might start listening to focusin/focusout instead which would cause our current fireEvent.focus implementation to not register React focus events. We should also fire focusin/focusout once they start doing that (i.e. react@next starts breaking the build) which is similar to how we handle mouseEnter/mouseLeave.

Ideally we'd get everybody on board to using .focus() and blur() instead but that would only work with jsdom@16.3.0 or a browser which is less than ideal.

How:

Assert on invocation of event handlers for bubbled events

Checklist:

  • [ ] Documentation added to the
    docs site
  • Tests
  • [ ] Typescript definitions updated
  • Ready to be merged

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 4, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f616c21:

Sandbox Source
React Configuration
kentcdodds/react-testing-library-examples Configuration

@codecov
Copy link

codecov bot commented Aug 4, 2020

Codecov Report

Merging #757 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #757   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          101       101           
  Branches        16        16           
=========================================
  Hits           101       101           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b82773c...f616c21. Read the comment docs.

@eps1lon eps1lon merged commit 0405f56 into testing-library:master Aug 4, 2020
@eps1lon eps1lon deleted the test/focus-bubble branch August 4, 2020 19:13
@kentcdodds
Copy link
Member

🎉 This PR is included in version 10.4.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants