Skip to content

test: try the suite on React Native with vitest-pool-react-native - #391

Draft
rexxars wants to merge 7 commits into
mainfrom
ci/react-native-pool
Draft

rexxars wants to merge 7 commits into
mainfrom
ci/react-native-pool

Conversation

@rexxars

@rexxars rexxars commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

An experiment, not meant to merge: it shows that the existing test/client.test.ts can run on React Native without changes to the tests, and what it reports. The suite is expected to fail.

vitest-pool-react-native bundles the test file and src/ with Metro and runs them in Hermes in a stock React Native app, on an iOS simulator and an Android emulator. vitest.react-native.config.ts has an ios and an android project, both reusing the shared config and the standalone test server from the Node suite. test:react-native runs them locally, and the Test: React Native (iOS) and Test: React Native (Android) jobs run them in CI.

The only change to existing code is adding 'react-native' to the Suite type in test/helpers/env.ts.

What to review:

  • The Android emulator can't reach the test server on 127.0.0.1, because the pool only forwards Metro's port with adb reverse. It doesn't matter yet, since nothing gets past module loading, but I expect the Android tests to fail on connections for reasons unrelated to the library once they do.
  • I couldn't build the iOS host locally (no iOS platform in my Xcode), so CI is the only place this has run.

What CI showed so far:

  • Metro first failed on vite/dist/node/module-runner.js, because test/helpers/env.ts imports inject from vitest. Listing it in the pool's testHelpers fixed that.
  • The pool then needed inject support (vitest-pool-react-native 2.1.0) and had to report errors thrown while a module loads (fix: report errors thrown while a module loads rexxars/vitest-pool-react-native#14, released in 2.1.1). Without that, a throwing import showed up as a timeout on Android and an undefined EventSource on iOS.
  • With 2.1.1, both platforms fail in the library: ReferenceError: Property 'EventTarget' doesn't exist at src/EventSource.ts:183, where EventSourceImpl extends EventTarget. Hermes in React Native 0.81.5 has no global EventTarget.
  • test/client.test.ts also uses vi.stubGlobal (the pool's runner doesn't export vi) and DOMException (not available in React Native), and fetch response streaming is untested so far.
  • The first launch on the iOS runner sometimes stalls waiting for the app to contact Metro. The pool's startup recovery restarts the simulator and retries.

@rexxars
rexxars force-pushed the ci/react-native-pool branch from e0d96d6 to 45a02f0 Compare November 22, 2026 12:56
The branch was merged and deleted upstream, so the Android job failed at the clone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant