Skip to content

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

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

rexxars wants to merge 5 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. vitest.react-native.config.ts reuses the shared config and the standalone test server from the Node suite. test:react-native runs it locally and a new Test: React Native (iOS) job runs it in CI.

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

What to review:

  • There's no Android project. An emulator can't reach the test server on 127.0.0.1, and the pool only forwards Metro's port, so Android would fail for reasons unrelated to the library.
  • The CI job references the pool's action on a branch (feat/action-config-input), because the action had no way to pick a config file. It should move to @main once that is merged.
  • 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). Without that, a throwing import showed up as a timeout on Android and an undefined EventSource on iOS.
  • With both in place, the first real failure is 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 for 120s waiting for the app to contact Metro. The pool's startup recovery restarts the simulator and retries.

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