Skip to content

Ancestor retrivals #4901

@Izocel

Description

@Izocel

Did you test using the latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Did your test fail and you're not sure why?

  • I have read the troubleshooting guide and it didn't help me.

What happened?

Since RN updates and detox updates our child retrivals has stopped working.

Spec flake

const parent: TestElement = element(by.id("parent"));
let child: TestElement = element(by.id("child"));

await d_expect(parent).toBeVisible(); // PASS
await d_expect(child).toBeVisible(); // PASS
await d_expect(child).toHaveText("Login Screen"); // PASS

//FIXME: Use ancestor matcher to find the child within the parent (does not work currently)
child = element(by.id("child").withAncestor(by.id("parent")));
await d_expect(child).toBeVisible(); // FAILS

DOM/View flake

    return (
      <Fragment>
        <View testID="parent">
          <Text testID="child">Login Screen</Text>
        </View>
      </Fragment>
    );
  }

What was the expected behaviour?

Hold specs should pass after migration

Help us reproduce this issue!

No response

In what environment did this happen?

Detox version: latest
React Native version: latest
Has Fabric (React Native's new rendering system) enabled: (yes/no) NewArch enabled Hermes enabled
Node version: 22.20
Device model: Samsung-A53
Android version: Android 16 API 39
Test-runner (select one): jest + babel +typescript
Jest: ^29.0.0

Detox logs

Detox logs
 npx detox test --configuration android.debug app.spec.ts
[[email protected]] injecting env (5) from .env -- tip: ⚙️  suppress all logs with { quiet: true }
14:45:52.455 detox[39028] B jest --config jest.config.cjs app.spec.ts
14:46:59.413 detox[39840] i app.spec.ts is assigned to AttachedDevice:R5CW10PPKLL
14:47:18.933 detox[39840] i The app seems to be idle
14:47:18.973 detox[39840] i Application specs: Should be able to focus in/out the app, without killing the app
14:47:22.299 detox[39840] i Application specs: Should be able to focus in/out the app, without killing the app [FAIL]
14:47:22.301 detox[39840] i Application specs: Should be able to translate keys
14:47:27.881 detox[39840] i Application specs: Should be able to translate keys [OK]

14:47:28.952 detox[39840] i The app seems to be idle
 FAIL  specs/suites/app/app.spec.ts (88.136 s)
  Application specs
    × Should be able to focus in/out the app, without killing the app (1244 ms)
    √ Should be able to translate keys (60 ms)

  ● Application specs › Should be able to focus in/out the app, without killing the app

    Test Failed: '(view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area)' doesn't match the selected view.
    Expected: (view has effective visibility <VISIBLE> and view.getGlobalVisibleRect() covers at least <75> percent of the view's area)
         Got: was null

      24 |
      25 |     //FIXME: Use ancestor matcher to find the child within the parent (does not work currently)
    > 26 |     child = element(by.id("child").withAncestor(by.id("parent"))).atIndex(0);
         |                           ^
      27 |     await d_expect(child).toBeVisible();
      28 |
      29 |     // Set value for email input

      at createErrorWithUserStack (node_modules/detox/src/utils/errorUtils.js:36:27)
      at Client._doSendAction (node_modules/detox/src/client/Client.js:168:32)
      at Client._sendMonitoredAction (node_modules/detox/src/client/Client.js:161:25)
      at Client.sendAction (node_modules/detox/src/client/Client.js:147:14)
      at Client.execute (node_modules/detox/src/client/Client.js:132:25)
      at InvocationManager.execute (node_modules/detox/src/invoke.js:11:39)
      at MatcherAssertionInteraction.execute (node_modules/detox/src/android/interactions/native.js:23:31)
      at NativeExpectElement.toBeVisible (node_modules/detox/src/android/core/NativeExpect.js:25:137)
      at Object.toBeVisible (specs/suites/app/app.spec.ts:26:27)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 passed, 2 total
Snapshots:   0 total
Time:        93.367 s
Ran all test suites matching /app.spec.ts/i.
14:47:32.333 detox[39028] E Command failed with exit code = 1:
jest --config jest.config.cjs app.spec.ts

Device logs

Device logs
paste your device.log here!

Test project deps

{
    "@babel/core": "latest",
    "@babel/preset-env": "latest",
    "@babel/preset-typescript": "latest",
    "@react-native/babel-preset": "latest",
    "@react-native/typescript-config": "latest",
    "@types/jest": "latest",
    "@types/node": "latest",
    "babel-jest": "latest",
    "detox": "latest",
    "detox-cli": "latest",
    "dotenv": "latest",
    "jest": "^29.0.0",
    "patch-package": "latest",
    "typescript": "latest"
}

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions