-
Notifications
You must be signed in to change notification settings - Fork 49.1k
Description
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 like SyntheticEvent
or ReactDOMComponentTree
. The “bad” requires are already marked with a TODO in tests so you won’t miss them.
To help with this:
- Find
// TODO: can we express this test with only public API?
in the unclaimed test files below. - Comment in this issue if you want to take a particular unit test file, with its name.
- Submit a PR that rewrites the test to use public APIs instead.
Step 3 requires some thinking. You can use previous examples where we rewrote tests with public API for inspiration. For example:
- Use only public API in CSSProperty-test #10429
- Rewrite DOMPropertyOperations-test in terms of public API #10281
- [Fiber] Remove stack dependencies from tests #9080
- Rewrite some tests relying on internal APIs #8148
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) #11742 -
Rewrote 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.