Issue 1:
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:

#10429

#10281

#9080

#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 #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) #11742

ReactIncrementalPerf-test.js (taken by @dphurley) #11724

SelectEventPlugin-test.js (taken by @skiritsis) #11299

ReactTreeTraversal-test.js (taken by @timjacobi) #11664

SyntheticKeyboardEvent-test.js + getEventCharCode-test.js (taken by @aarboleda1)

escapeTextContentForBrowser-test.js (taken by @jeremenichelli) #11331

inputValueTracking-test.js

quoteAttributeValueForBrowser-test.js (taken by @jeremenichelli) #11331

ReactDOMComponent-test.js (taken by @AudyOdi) #11337

ReactDOMComponentTree-test.js (taken by @GordyD) #11383

ReactDOMEventListener-test.js (taken by @enapupe) #11327

ReactDOMInput-test.js (taken by @SadPandaBear) #11309

ReactDOMServerIntegration-test.js (taken by @minerado)

setInnerHTML-test.js (taken by @silvestrijonathan) #11385

#11631

getEventKey-test.js (taken by @mjw56) #11317

SyntheticClipboardEvent-test.js (taken by @smaniotto) #11365

SyntheticEvent-test.js (taken by @timjacobi) #11525

SyntheticWheelEvent-test.js (taken by @douglasgimli) #11367

ChangeEventPlugin-test.js (taken by @Ethan-Arrowood) #11333

EnterLeaveEventPlugin-test.js (taken by @accordeiro) #11316

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.

Issue 2:
Guys, I'm starting my holidays next week, and also I need this in one of my projects.

I was discussing this with @zpao in one of issue discussions here.

Basically the idea is to take ember-rails code and use it to expose react.js and jsxtransformer.js in assets/.

Second thing would be to register sprockets engine to transform JSX, we could steal a bit of code from https://github.com/leshill/handlebars_assets and using execjs run jsxtransformer. I already tested all this and it works ok. Good thing we have a patch merged to allow jsx transformation using non-node, non-browser JS environment: #217

If no one is in a hurry about this, I would start making this gem, restructure the repo a bit (move all gem files into gems/ dir) and make all that's necessary to have a proper react-rails gem. I should be ready with an initial version of this some time next week.

PR will follow.