`@effect/ui-native` (Effect-TS/ui): `Native.Host` is in `Command.FrameworkServices` (`R = never`) but missing from `@effect/ui-native/testing`

Abierto
#11,092 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
76/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
react-native, typescript
Área
mobile, testing

Línea de trabajo

Read packages/ui-native/src/testing/index.ts and the TestDevice.layer(...) implementation, then compare their provided services with Native.Host in packages/ui-native/src/Native.ts. Run the supplied Vitest reproduction to confirm the missing service. Done when native Play or Scene tests provide a usable Native.Host and the reproduction runs without the service-not-found error.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

partially generated with help of my ai friend - neon 4.4

Hi effect team,
I was trying out this package and wanted to report some bugs encountered while porting a library to effect native

What version of Effect is running?
  • effect: 4.1.7
  • @effect/ui & @effect/ui-native: Effect-TS/ui main at 77391ee50ae3d3175d670facbf675e9a819ba6a6
  • react-native: 0.88.1
What steps can reproduce the bug?
  1. Clone the minimal reproduction repository:
    git clone https://github.com/cliffordfajardo/effectui-native-error-reproductions.git
    cd effectui-native-error-reproductions
    pnpm install
    pnpm vitest run 06-native-host-missing-in-testing-layer
    
  2. Write a Native.component whose Command.make yields Native.Host (for example calling host.measure(node) or host.scrollTo(...) — the same pattern used internally by @effect/ui-native/kit/VirtualList):
const measureCmd = Command.make(
  Effect.fn(function*() {
    const refs = yield* Renderer.Refs
    const host = yield* Native.Host
    const node = refs.get("box") as NativeHost.NativeNode | undefined
    return node ? host.measure(node) : undefined
  })
)
  1. Run the component in a Vitest Play.make test using the documented native test layers Layer.merge(TestHost.layer(), TestDevice.layer("ios")) (see 06-native-host-missing-in-testing-layer/repro.test.ts).
What is the expected behavior?

Because Native.Host is declared in Command.FrameworkServices (packages/ui-native/src/Native.ts:1239-1243), TypeScript intentionally does not require tests to provide Native.Host manually (R = never). Accordingly, @effect/ui-native/testing (e.g. TestDevice.layer(...) or a dedicated TestNativeHost.layer(...)) should provide a working test Native.Host service so components using measure, scrollTo, focus, blur, etc. run cleanly in Play / Scene tests.

What do you see instead?

The test compiles with R = never, then fails at runtime as soon as the command executes:

Error: Service not found: @effect/ui-native/Native/Host

NativeApp.register provides Native.Host on real devices, but @effect/ui-native/testing (packages/ui-native/src/testing/index.ts) currently only exports TestDevice and provides no Native.Host implementation.

Additional information

Possible fix:

  • Provide a default/configurable Native.Host implementation from TestDevice.layer(...) (or export TestNativeHost.layer(...) from @effect/ui-native/testing) that records scrollTo / focus / blur / command calls and lets tests stub measure(node) rects.
Lenguaje dominante
TypeScript
Estrellas
16.7k
Forks
808
Merge medio
21 h 22 min
PR fusionados (30 d)
486

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Effect-TS/effect

Todos los issues de Effect-TS/effect

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.