`@effect/ui-native` / `@effect/ui/testing` (Effect-TS/ui): `Locator.testId` only matches HTML `attrs["data-testid"]` and cannot locate React Native `.prop("testID", ...)`

Aperta
#11,079 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@effect-bot ci sta già lavorando.

Dal 29/11/2026.

  • #647 di @effect-bot — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
react-native, typescript
Ambito
testing

Direzione di ricerca

Start with packages/ui/src/testing/Locator.ts, where testId matches data-testid, and compare it with the native props described in the issue. Check the existing locator tests and the native testing exports in packages/ui-native/src/testing/index.ts. Done means Locator.testId("save-button") can find a node tagged through .prop("testID", "save-button") and the behavior is covered by a test; an open linked pull request is already addressing this issue.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 test
    
  2. Render a Native.component that sets React Native's standard testID prop via .prop("testID", "save-button"):
const ActionButton = Native.component({
  name: "ActionButton",
  model: Schema.Number,
  message: Message
}).make({
  init: () => 0,
  update: {
    Pressed: ($) => $.model + 1
  },
  view: (h, count) =>
    h.view
      .prop("testID", "save-button")
      .on("press", () => Message.Pressed())
      .children(h.text.children(`Saved ${count}`))
})
  1. Query the rendered tree in a Play test using Locator.testId("save-button") (see 01-locator-testid-misses-native-props-testid/repro.test.ts).
What is the expected behavior?

Locator.testId("save-button") (or a native locator / Locator.prop(...) helper exported from @effect/ui/testing or @effect/ui-native/testing) should find native elements whose testID was set with .prop("testID", "save-button"), so Play and Scene tests can target native nodes by test ID without writing custom tree-walking locators.

What do you see instead?

packages/ui-native/src/Native.ts:668 defines readonly testID?: string | undefined on ViewProps, which writes to node.props.testID while leaving node.attrs empty.

However, packages/ui/src/testing/Locator.ts:188 implements testId strictly against HTML attributes:

export const testId = (id: string): Locator => attr("data-testid", id)

Even though Locator.Node (packages/ui/src/testing/Locator.ts:45-51) already models readonly props?: Readonly<Record<string, unknown>> | undefined, Locator.testId("save-button") returns [] for native views, causing play.expect(Locator.testId("save-button")).toExist() to fail.

Additionally, @effect/ui/testing does not export a Locator.prop(name, value) builder, and @effect/ui-native/testing (packages/ui-native/src/testing/index.ts) currently only exports TestDevice.

Additional information

In React Native / Fabric, .prop("testID", id) maps to native accessibility identifiers (e.g. accessibilityIdentifier on iOS) and is the idiomatic way to tag custom components for both component tests and native E2E tests.

Possible fixes:

  • Have Locator.testId(id) match either node.attrs?.["data-testid"] === id or node.props?.testID === id, and/or
  • Export Locator.prop(name, value?) from @effect/ui/testing (and optionally a NativeLocator.testID helper from @effect/ui-native/testing).
Lingua principale
TypeScript
Stelle
16.7k
Fork
808
Merge medio
21h 22m
PR unite (30g)
486

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Effect-TS/effect

Tutte le issue di Effect-TS/effect

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.