-
Notifications
You must be signed in to change notification settings - Fork 47.5k
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
Add tests for non-React discrete events flushing in a microtask #20772
Conversation
I'm planning to copy paste so why not update them anyway.
These are still using React events. I'll change that next.
// Verify that the second button was removed. | ||
await null; | ||
expect(submitButtonRef.current).toBe(null); | ||
// We'll assume that the browser won't let the user click it. |
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.
The original test was more interesting here because it fired an event and verified that React ignores it. However, if we fire an event manually on a DOM node, and listen directly on that node with a native listener, it would still fire. So I don't know what we should be testing here. I think just testing that the DOM node was removed is enough because the rest is up to the browser.
firstEvent.initEvent('click', true, true); | ||
expect(() => | ||
dispatchAndSetCurrentEvent(disableButton, firstEvent), | ||
).toErrorDev(['An update to Form inside a test was not wrapped in act']); |
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.
Using act would defeat the point of this test
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.
Add as inline comment?
Comparing: 97fce31...f945f3a Critical size changesIncludes critical production bundles, as well as any change greater than 2%:
Significant size changesIncludes any change greater than 0.2%: (No significant 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.
Looks great
…book#20772) * Convert some old discrete tests to Hooks I'm planning to copy paste so why not update them anyway. * Copy paste discrete tests into another file These are still using React events. I'll change that next. * Convert the test to use native events
Adds some tests for #20748.
They're based on existing tests we have for React events. I converted the old tests to Hooks while I'm at it.
See individual commits.