-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Express more tests via public API #11299
Comments
I can take a look at this over the weekend and see if I can tackle it in the short term. |
Great, thanks! If you pick any particular test, please comment with the filename in the thread so that someone else doesn’t start working on the same test. |
I am definitely very interested in contributing to this. I will look through this weekend and find an opportunity to refactor! |
I am interested as well 👍 |
I published a list of tests in the first post. Just let me know which ones you’d like to take and I’ll assign them to you. |
|
@SadPandaBear You got it! |
I can work on |
I will take a look at |
I'll do |
I can work on |
I can take |
I'd like to give |
I can take |
I'd like to work on |
I'd like to work on |
I would like to take |
I'd like to take SyntheticKeyboardEvent-test.js. Thanks 👍 |
Let me take |
I'd like to work on |
Can I take: |
I'm taking |
I'd like to work on |
I'd like to work on ReactTreeTraversal-test.js |
hi! 👋 I'd like to work on |
* Rewrite tests using only public API. * Modified the tests to prevent duplication of code. * Code review changes implemented. * Removed the .internal from the test file name as its now written using public APIs.
* ValidateDOMNesting tests(#11299) * Rewrite tests using only public API. * Modified the tests to prevent duplication of code. * Code review changes implemented. * Removed the .internal from the test file name as its now written using public APIs. * Remove mutation * Remove unnecessary argument Now that we pass warnings, we don't need to pass a boolean. * Move things around a bit, and add component stack assertions
…facebook#11309) * Rewrite tests depending on internal API * Remove focus being called when there was no blur event function before * Remove triggering function and just let ReactTestUtils take care * Use native events * Remove duplicate * Simulate native event when changing value on reentrant * Change wasn't being called * Use Simulate only * Use React event handlers on test * Move commentary * Lint commit * Use native event * Comment native event dispatching * Prettier * add setUntrackedValue * Prettier-all * Use dispatchEvent instead of ReactTestUtils Simulates; * Prettier * Fix lint * Remove useless arg * Wrap event dispatcher into function * Remove deprecated Event * Remove unused change event dispatcher * Fix merge * Prettier * Add missing focus/blur calls They are necessary to cover for the fix in facebook#8240.
* Use only public API for EnterLeaveEventPlugin Tests (facebook#11299) * Trigger native event to test EnterLeaveEventPlugin (facebook#11299) * Rewrite EnterLeaveEventPlugin tests to use dispatchEvent * Update EnterLeaveEventPlugin test to use OnMouseLeave event * Add coverage for onMouseEnter too
…#11317) * Add flow annotation to getEventKey. * Remove Simulate and SimulateNative for native events. * Style nits * Oops
…11299) (facebook#11367) * Update SyntheticWheelEvent tests to use public API * Replace: ReactTestUtils.SimulateNative to native Events() * Update: Replaced WheelEvent() interface to document.createEvent * Fix: Lint SyntheticWheelEvent file * Update: Custom WheelEvent function to a generic MouseEvent function * Update: Prettier SyntheticWheelEvent-test.js * Verify the `button` property is set on synthetic event * Use MouseEvent constructor over custom helper * Rewrite to test React rather than jsdom * Force the .srcElement code path to execute * Style tweaks and slight code reorganization
…acebook#11383) * Rewrite ReactDOMComponentTree-test to test behavior using Public API - Part of facebook#11299 - I've tried to identify cases where code within ReactDOMComponentTree is exercised and have updated accordingly but I'm not entirely sure whether I'm on the right track. I thought I'd PR to get feedback from the community. Looking forward to comments. * Prettier and lint changes * Remove testing of internals and add test cases for testing behavior exhibited after use of getInstanceFromNode * [RFC] Update testing approach to verify exhibited behavior dependent upon methods in ReactDOMComponentTree * Remove tests from event handlers and use sync tests * Prettier changes * Rename variables to be more semantic * Prettier updates * Update test following review - Use beforeEach and afterEach to set up and tear down container element for use in each test - Move any functions specific to one test to within test body (improves readability imo) * Add coverage for getNodeFromInstance and implementation of getFiberCurrentPropsFromNode - After researching usage of getNodeFromInstance we can test getNodeFromInstance dispatching some events and asserting the id of the currentTarget - After checking git blame for getFiberCurrentPropsFromNode and reading through facebook#8607 I found a test that we can simplify to assert behavior of the function by ensuring event handler props are updated from the fiber props. Swapping out the implementation of this function with `return node[internalInstanceKey].memoizedProps` results in a failure.
Ping @reznord |
Hi @gaearon, Can I take |
hi, @gaearon is there something that I can do in |
Hi, Does anyone can help me to continue the ReactBrowserEventEmitter-test.js test ? Because I'll busy on my working now no time to keep going, the PR is #11713, thank you so much !! |
Thanks to everyone again! There are still a few outstanding tests but I think we can close it. |
@gaearon : |
This is a great contribution opportunity.
We need to rewrite more unit tests in terms of public API.
This means that they can only import npm entry points like
react
,react-dom
,react-dom/test-utils
,react-test-renderer
, etc, but not internal modules likeSyntheticEvent
orReactDOMComponentTree
. The “bad” requires are already marked with a TODO in tests so you won’t miss them.To help with this:
// TODO: can we express this test with only public API?
in the unclaimed test files below.Step 3 requires some thinking. You can use previous examples where we rewrote tests with public API for inspiration. For example:
Generally, you need to think about how the behavior you’re testing actually reproduces in a React app, and then test for that. In rare cases it may involve exposing some API as public which we’ll need to discuss separately, so don’t hesitate to start a discussion! If you can’t figure out how to rewrite some particular test with a public API, comment here and we can brainstorm.
Here is the full list of tests that need to change. Some of them may be simple one-liner changes, some may involve a bit of a rewrite, some may require rewriting from scratch. Some may even be impossible, but research leading to that conclusion is still very valuable and we’d love to know that.
Try them and let us know:
Update: all tests are taken now. Subscribe to this issue! They might free up in the future if somebody doesn’t have the time to finish the work. We’ll comment if some test becomes available to try again.
ReactBrowserEventEmitter-test.js
(taken by @madeinfree, see Express more tests via public API #11299 (comment))getNodeForCharacterOffset-test.js
(taken by @accordeiro)ReactErrorUtils-test.js
(taken by @reznord)BeforeInputEventPlugin-test.js
+FallbackCompositionState-test.js
(taken by @GordyD)validateDOMNesting-test.js
(taken by @anushreesubramani) ValidateDOMNesting tests(#11299) #11742Rewrote ReactIncrementalPerf-test using only public API.(#11299) #11724ReactIncrementalPerf-test.js
(taken by @dphurley)Express more tests via public API #11299SelectEventPlugin-test.js
(taken by @skiritsis)Rewrite ReactTreeTraversal-test.js using public APIs #11664ReactTreeTraversal-test.js
(taken by @timjacobi)SyntheticKeyboardEvent-test.js
+getEventCharCode-test.js
(taken by @aarboleda1)Drop .textContent IE8 polyfill and rewrite escaping tests against public API #11331escapeTextContentForBrowser-test.js
(taken by @jeremenichelli)inputValueTracking-test.js
Drop .textContent IE8 polyfill and rewrite escaping tests against public API #11331quoteAttributeValueForBrowser-test.js
(taken by @jeremenichelli)Remove tests in ReactDOMComponent-test depending on internal API #11337ReactDOMComponent-test.js
(taken by @AudyOdi)Rewrite ReactDOMComponentTree-test to test behavior using Public API #11383ReactDOMComponentTree-test.js
(taken by @GordyD)Use only public api for ReactDOMEventListener-test.js #11327ReactDOMEventListener-test.js
(taken by @enapupe)Rewrite ReactDOMInput-test depending on internal API (#11299) #11309ReactDOMInput-test.js
(taken by @SadPandaBear)ReactDOMServerIntegration-test.js
(taken by @minerado)Rewrite setInnerHTML tests to use Public API. #11385setInnerHTML-test.js
(taken by @silvestrijonathan)Refactor SyntheticKeyboardEvent tests to only use the public API #11631
Update getEventKey tests to use public API (#11299) #11317getEventKey-test.js
(taken by @mjw56)Refactor SyntheticClipboardEvent tests to only use the public API #11365SyntheticClipboardEvent-test.js
(taken by @smaniotto)Rewrite SyntheticEvent tests using public APIs only #11525SyntheticEvent-test.js
(taken by @timjacobi)Rewrite SyntheticWheelEvent-test depending on internal API (#11299) #11367SyntheticWheelEvent-test.js
(taken by @douglasgimli)Use only public API for ChangeEventPlugin-test.js #11333ChangeEventPlugin-test.js
(taken by @Ethan-Arrowood)Use only public API for EnterLeaveEventPlugin Tests #11316EnterLeaveEventPlugin-test.js
(taken by @accordeiro)ReactCoroutine-test.js
(taken by @jstejada)ReactFiberHostContext-test.js
(taken by @adsonpleal)First-time contributor? Refer to our contribution instructions.
Not clear how to fix a specific test? Comment with what you tried, and we can brainstorm.
If you gave up on some test, please post your findings in a comment so we can decide what to do next. It’s fine if you just didn’t find the time or couldn’t figure it out—we can try to help, and maybe somebody else can pick it up later.
The text was updated successfully, but these errors were encountered: