Navigation Menu

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

Always set window.event in test environment #20777

Closed
wants to merge 1 commit into from

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Feb 9, 2021

To avoid future surprises and confusion. Let's just do it everywhere.

I'm not sure this is exactly accurate and matches how the browser does it. Probably not. But close enough?

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Feb 9, 2021
@sizebot
Copy link

sizebot commented Feb 9, 2021

Comparing: ad8211d...f55f74d

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.min.js = 122.48 kB 122.48 kB = 39.45 kB 39.45 kB
oss-experimental/react-dom/cjs/react-dom.production.min.js = 129.06 kB 129.06 kB = 41.50 kB 41.50 kB
facebook-www/ReactDOM-prod.classic.js = 406.84 kB 406.84 kB = 75.42 kB 75.42 kB
facebook-www/ReactDOM-prod.modern.js = 395.19 kB 395.19 kB = 73.54 kB 73.54 kB
facebook-www/ReactDOMForked-prod.classic.js = 406.85 kB 406.85 kB = 75.42 kB 75.42 kB

Significant size changes

Includes any change greater than 0.2%:

(No significant changes)

Generated by 🚫 dangerJS against f55f74d

@acdlite
Copy link
Collaborator

acdlite commented Feb 9, 2021

Hmm. Will most users run their tests in an environment with window.event? What does JSDOM do? How will React Testing Library work?

Maybe we should warn if it's undefined? Though then we need some guidance for fixing it.

@gaearon
Copy link
Collaborator Author

gaearon commented Feb 9, 2021

Hmm yeah good point. The answer is I have no idea. I'll ask Twitter.

@gaearon
Copy link
Collaborator Author

gaearon commented Feb 9, 2021

Maybe we should warn if it's undefined?

How would you know you're in an event though?

What does JSDOM do?

Seems like it doesn't do anything, as it's sort of a legacy property. At least our version doesn't.

How will React Testing Library work?

I think RTL could do something like this as part of its setup. Or in its fireEvent wrapper.

@crypt096
Copy link

crypt096 commented Oct 4, 2021

Please resolve conflicts.

@sebmarkbage sebmarkbage deleted the branch facebook:master October 20, 2022 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants