Skip to content

With two copies of react-native, a native component a test registers is unknown to the renderer #215

Open

Description

@YevheniiKotyrlo

Describe the bug

When a project resolves two copies of react-native, the bundle Harness builds carries both, and a native component a test registers with requireNativeComponent is unknown to the renderer. Rendering it throws

Invariant Violation: View config getter callback for component `SolidColorTextureView` must be a function (received `undefined`).

and anything that relies on the registry fails the same way: the playground's ui/type.harness.tsx fails all five of its tests with Unable to find element with testID: text-input on Android.

The playground has two copies since #196: apps/playground/node_modules/react-native and the root one, both 0.82.1 but distinct pnpm instances (their @react-native/metro-config peers are 0.82.1 and 0.83.0). As #207 describes, the Harness runtime resolves the root copy, and the bundle renders through it, while the playground's test files resolve the playground's copy.

I have a fix that resolves react-native and react, the runtime's peer dependencies, from the project for every module, so the bundle holds the app's copy only, and #207's remap is no longer needed. I can open a PR.

System Info

System:
  OS: Windows 11 10.0.26200
Binaries:
  Node: 26.8.1
react-native: 0.82.1 (apps/playground)
Device: Android emulator, API 35, x86_64

React Native Harness Version

1.6.0 (main at bca0781)

Reproduction

https://github.com/callstackincubator/react-native-harness/tree/main/apps/playground

Steps to reproduce

  1. Build the playground for Android (with Android playground doesn't build: its Gradle plugin and codegen come from the workspace root #214's fix, since main's Gradle build fails) and install the APK.
  2. Run react-native-harness --harnessRunner android src/__tests__/normal/ui/type.harness.tsx in apps/playground.
  3. All five tests fail with Unable to find element with testID: text-input. With every react-native import resolved from the playground, they pass.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions