Repository navigation
Description
Hi! First of all, thanks for 0.14 — the Expo module table per SDK and the package mocks took a whole layer off our hands in vitest-expo, a thin jest-expo-style preset that sits on top of vitest-native. This is a proposal that came out of that move, not a bug report.
The situation
Some Expo packages use the presence of a native module as an environment probe. The clearest case is Expo Go: isRunningInExpoGo() in expo is nothing more than "does the ExpoGo native module exist". expo-notifications branches on it — DevicePushTokenAutoRegistration.fx.js skips the registration path and warns on Android, and warnOfExpoGoPushUsage.js throws for push-token calls. EXDevLauncher is a similar probe on the legacy bridge: expo-constants reads its presence as "a development launcher supplied the manifest".
jest-expo keeps ExpoGo present on purpose (there is a comment in internalExpoModules.js: "tests rely on it existing so isRunningInExpoGo() stays true"), and since 0.14 the native engine follows jest-expo here, which is the right default for parity.
For a suite that models a development build rather than Expo Go — which is what vitest-expo promises its users ("tests behave like a dev build") — that answer is the wrong one: real expo-notifications code takes its Expo Go branches, and a test that exercises push registration on Android throws.
What we do today
There is no option for it. nativeModules: 'permissive' goes the other way (every name present), and mockNativeModule() registers a module rather than removing one. So vitest-expo wraps the resolver's present() through globalThis.__vitest_native_expo_modules before any Expo package loads: src/runtime/dev-build.ts. It works, and a conformance test pins it, but it leans on an internal global that is not part of your API, and we would rather not depend on it.
Proposal
A small opt-in beside the existing nativeModules option, for example:
reactNative({
nativeModules: { absent: ['ExpoGo', 'EXDevLauncher'] },
})applied in createExpoNativeModuleResolver's present(name) (src/native/expo-native-modules.mjs) before the other layers, so a listed name reads as absent in globalThis.expo.modules (both get and has), requireOptionalNativeModule() returns null for it, and requireNativeModule() throws as it does on a device. The default stays as it is, jest-expo parity.
If that shape fits, I am happy to send the PR, with the option validated like the others and a test in tests-native. If you would rather keep this out of the engine, that is fine too — then we keep our wrapper and I will note in our code that it is deliberate.
Activity
[-]Native engine: a way to make a native module read as absent (ExpoGo, EXDevLauncher)[/-][+]Proposal: an option to make a native module read as absent (for tests that model a development build)[/+]danfry1 commentedon Nov 3, 2026
Thanks @swey, and thanks for the kind words on 0.14. The use case is real, and depending on an internal global is fragile for both of us, so we'd like to support this properly.
Looking into it, a list of absent names turns out not to be quite enough, for three reasons:
EXDevLauncheris registered by expo-dev-launcher in debug builds, so a development build has it; it's also already absent by default here, so listing it changes nothing.TurboModuleRegistry, and undernativeModules: 'permissive'that answers every name, soisRunningInExpoGo()would still be true.executionEnvironment: 'bare'andappOwnership: nullin expo-constants, which expo-linking branches on; removingExpoGoalone would leave those saying Expo Go.So we'd like to model the runtime itself, e.g.
reactNative({ expo: { runtime: 'development-build' } }), with each fact (ExpoGo absent wherever a module can be looked up, EXDevLauncher present when expo-dev-launcher is installed, the Constants values) checked against Expo's own source. Since it cuts across the engine's native-module boundary in a few places, we'll build it in-tree. We'd really value your review of the PR, and a run against your suite before it ships. One note: Expo readsExpoGowhen the module loads, so this is a per-project setting; suites that need both runtimes can use separate Vitest projects.Thanks again for raising it. I'll link the PR here.