Skip to content

feat(native): run tests as an Expo development build with expo.runtime - #431

Draft
danfry1 wants to merge 6 commits into
mainfrom
feat/expo-runtime-development-build
Draft

danfry1 wants to merge 6 commits into
mainfrom
feat/expo-runtime-development-build

Conversation

@danfry1

@danfry1 danfry1 commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

reactNative({ expo: { runtime: 'development-build' } }) runs native-engine tests as an Expo development build instead of Expo Go. Requested in #418.

Why

Expo tells its runtimes apart by asking native modules, and the engine always answered as Expo Go, so isRunningInExpoGo() was true and code for development builds could not be tested. Removing ExpoGo from expo.modules alone is not enough: expo-modules-core falls back to TurboModuleRegistry, which answers every name under nativeModules: 'permissive'.

Changes

  • With the option, ExpoGo is absent from expo.modules, NativeModules and TurboModuleRegistry, and getEnforcing('ExpoGo') throws React Native's own error. EXDevLauncher is present only when expo-dev-launcher is installed, with no manifest. expo-constants reports executionEnvironment: 'bare' and appOwnership: null.
  • Both registries now use one presence check, including expo.modules before the Expo resolver exists in a hot worker. Precedence: mockNativeModule(), then the runtime, then a module's own seed, then the scans, then permissive mode. React Native core modules are never made absent.
  • The setting travels in the project context and is read at lookup time, so the registry cache is unaffected.
  • tests/expo-runtime-facts.test.ts reads each encoded fact from Expo's source: the workspace's SDK 58, and SDK 57 from the packed consumer install. test:native:expo-runtime runs the installed packages under the stock and hot runtimes.
  • Under the mock engine the option fails with EXPO_RUNTIME_REQUIRES_NATIVE_ENGINE. With the expo preset, whose expo-constants stand-in models Expo Go, 'development-build' fails with EXPO_RUNTIME_CONFLICTS_WITH_EXPO_PRESET. The default, also accepted as 'expo-go', is unchanged.

Notes

  • TODO: expo-dev-launcher is not a workspace dependency yet (pending approval), so its registration check is skipped in CI. Once it is installed, make that check fail rather than skip when CI is set and the package is missing (marked in tests/expo-runtime-facts.test.ts).
  • The runtime is per Vitest project. Expo reads it at module load, so the docs show two projects for suites that need both.

Nothing declared `expo`, so bun installed expo@56 to satisfy the peer of the
expo-constants and expo-status-bar devDependencies, an SDK outside the supported
range. Declaring expo@58.0.20 makes the package root an Expo project, so asset
tests that assumed a bare React Native root now check Metro's descriptor in an
explicit bare fixture root and Expo's descriptor for imports from this root.
…are root

The Android suite resolved the .android asset variant from the package root, which declaring expo made an Expo project. It now asserts Expo's descriptor for the required variant and resolves Metro's own descriptor, from a bare fixture root, as an Android drawable.
`reactNative({ expo: { runtime: 'development-build' } })` makes the native
engine answer Expo's runtime checks as a development build does: no ExpoGo
module in any registry, EXDevLauncher when expo-dev-launcher is installed,
and expo-constants' bare-workflow values. Both module registries now share
one presence check, so the option cannot be undone by a fallback lookup.
@danfry1
danfry1 changed the base branch from chore/expo-58-devdep to main November 3, 2026 23:18
@swey

swey commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the quick turn, and for taking it further than my list of names — the EXDevLauncher point and the permissive-mode fallback were both gaps in our wrapper.

Tried the branch build with vitest-expo setting the option instead of the wrapper: our conformance suite and a production SDK 58 app are both green, nothing reacts to executionEnvironment being 'bare'. Fits us as is; once it ships, vitest-expo sets the option by default. Happy to run both again on a later revision.

… preset

The expo preset's expo-constants stand-in models Expo Go, so combining it
with a development build reported two runtimes at once; the plugin now
fails with EXPO_RUNTIME_CONFLICTS_WITH_EXPO_PRESET. The packed SDK 57
consumer also runs the Expo runtime facts gate, expo.modules consults the
shared presence check before the Expo resolver exists, and
expo-dev-launcher detection reuses packageDirOf.
…elopment-build

# Conflicts:
#	packages/vitest-native/package.json
#	packages/vitest-native/src/native/boundary.mjs
#	packages/vitest-native/src/native/expo-native-modules.mjs
#	packages/vitest-native/src/native/native-modules.d.mts
#	packages/vitest-native/tests/errors.test.ts
@danfry1 danfry1 added enhancement New feature or request area:expo Expo SDK support, Expo runtime and native modules labels Nov 4, 2026
@danfry1 danfry1 modified the milestones: 0.15.0, 0.16.0 Nov 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:expo Expo SDK support, Expo runtime and native modules enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants