Skip to content

UI Kitten Switch: toHaveToggleValue(true) not working #4884

@Maschga

Description

@Maschga

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?

That's the checkbox:

import { CheckBox } from "@ui-kitten/components";

<CheckBox
  style={{ marginTop: 8, marginBottom: 16 }}
  checked={internalAuth.required}
  onChange={(v) => setInternalAuth({ ...internalAuth, required: v })}
  testID="serverFormAuth"
>
  {t("servers.manually.authenticationRequired")}
</CheckBox>

See https://github.com/evcc-io/app/blob/78a16df689e8d60c230ef0cdf96e40acee3351e6/components/ServerForm.tsx#L71-L77

What was the expected behaviour?

The test should not raise an exception.

Help us reproduce this issue!

I used this test:

await device.launchApp({
  newInstance: true,
  url: "evcc://server?url=https://localhost:7080&username=admin&password=secret",
}); // this means, the switch is set true on startup
console.log(await element(by.id("serverFormAuth")).getAttributes());
await expect(element(by.id("serverFormAuth"))).toHaveToggleValue(true);

In what environment did this happen?

Detox version: 20.46.0
React Native version: 0.81
Has Fabric (React Native's new rendering system) enabled: (yes/no) No idea, using Expo 54.0.12
Node version: v22.20.0
Device model: Samsung Galaxy A71
Android version: 12
Test-runner: jest

Detox logs

Detox logs

log.txt

Device logs

Device logs:
debug_logs.zip

More data, please!

The app:

Image

I'm not sure why Detox doesn't recognize the switch, but maybe it's because Ui Kitten renders the switch differently than Detox expects:

<ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="53" visibility="visible" alpha="1.0" focused="false" label="Anmeldung erforderlich" x="42" y="473" id="serverFormAuth">
  <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="53" height="53" visibility="visible" alpha="1.0" focused="false" x="42" y="473" />
  <SvgView class="com.horcrux.svg.SvgView" width="31" height="31" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
    <GroupView class="com.horcrux.svg.GroupView" width="0" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
      <GroupView class="com.horcrux.svg.GroupView" width="31" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
        <GroupView class="com.horcrux.svg.GroupView" width="31" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
          <RectView class="com.horcrux.svg.RectView" width="31" height="31" visibility="visible" alpha="1.0" focused="false" x="53" y="484" />
          <PathView class="com.horcrux.svg.PathView" width="23" height="17" visibility="visible" alpha="1.0" focused="false" x="57" y="491" />
        </GroupView>
      </GroupView>
    </GroupView>
  </SvgView>
  <ReactTextView class="com.facebook.react.views.text.ReactTextView" width="468" height="51" visibility="visible" alpha="1.0" focused="false" label="Anmeldung erforderlich" x="126" y="473" text="Anmeldung erforderlich" />
</ReactViewGroup>
Full hierarchy:
    <?xml version='1.0' encoding='UTF_8' standalone='yes' ?>
    <ViewHierarchy density="2.625">
      <DecorView class="com.android.internal.policy.DecorView" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
        <LinearLayout class="android.widget.LinearLayout" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
          <ViewStub class="android.view.ViewStub" width="0" height="0" visibility="gone" alpha="1.0" focused="false" x="0" y="0" />       
          <FrameLayout class="android.widget.FrameLayout" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
            <FitWindowsLinearLayout class="androidx.appcompat.widget.FitWindowsLinearLayout" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
              <ViewStubCompat class="androidx.appcompat.widget.ViewStubCompat" width="0" height="0" visibility="gone" alpha="1.0" focused="false" x="0" y="0" />
              <ContentFrameLayout class="androidx.appcompat.widget.ContentFrameLayout" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
                <ReactSurfaceView class="com.facebook.react.runtime.ReactSurfaceView" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" label="URL eingeben, https://localhost:7080, Anmeldung erforderlich, admin, secret, Prüfen und speichern" x="0" y="0">
                  <SafeAreaProvider class="com.th3rdwave.safeareacontext.SafeAreaProvider" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
                    <ScreenStack class="com.swmansion.rnscreens.ScreenStack" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
                      <ScreensCoordinatorLayout class="com.swmansion.rnscreens.stack.views.ScreensCoordinatorLayout" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
                        <Screen class="com.swmansion.rnscreens.Screen" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0">
                          <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" label="URL eingeben, https://localhost:7080, Anmeldung erforderlich, admin, secret, Prüfen und speichern" x="0" y="0">
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="1080" height="2400" visibility="visible" alpha="1.0" focused="false" x="0" y="0" />
                            <ReactTextView class="com.facebook.react.views.text.ReactTextView" width="912" height="116" visibility="visible" alpha="1.0" focused="false" label="URL eingeben" x="0" y="84" text="URL eingeben" />
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="168" height="116" visibility="visible" alpha="1.0" focused="true" x="912" y="84">
                              <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="84" height="84" visibility="visible" alpha="1.0" focused="false" x="954" y="95">
                                <SvgView class="com.horcrux.svg.SvgView" width="84" height="84" visibility="visible" alpha="1.0" focused="false" x="954" y="95">
                                  <GroupView class="com.horcrux.svg.GroupView" width="0" height="0" visibility="visible" alpha="1.0" focused="false" x="954" y="95">
                                    <GroupView class="com.horcrux.svg.GroupView" width="84" height="0" visibility="visible" alpha="1.0" focused="false" x="954" y="95">
                                      <GroupView class="com.horcrux.svg.GroupView" width="84" height="0" visibility="visible" alpha="1.0" focused="false" x="954" y="95">
                                        <RectView class="com.horcrux.svg.RectView" width="63" height="63" visibility="visible" alpha="1.0" focused="false" x="954" y="95" />
                                        <PathView class="com.horcrux.svg.PathView" width="46" height="46" visibility="visible" alpha="1.0" focused="false" x="973" y="114" />
                                      </GroupView>
                                    </GroupView>
                                  </GroupView>
                                </SvgView>
                              </ReactViewGroup>
                            </ReactViewGroup>
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" label="https://localhost:7080" x="42" y="284" id="@serverFormUrl/container">
                              <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" x="42" y="284" />
                              <ReactEditText class="com.facebook.react.views.textinput.ReactEditText" width="908" height="59" visibility="visible" alpha="1.0" focused="false" label="https://localhost:7080" x="86" y="317" text="https://localhost:7080" id="@serverFormUrl/input" />
                            </ReactViewGroup>
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="53" visibility="visible" alpha="1.0" focused="false" label="Anmeldung erforderlich" x="42" y="473" id="serverFormAuth">
                              <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="53" height="53" visibility="visible" alpha="1.0" focused="false" x="42" y="473" />
                              <SvgView class="com.horcrux.svg.SvgView" width="31" height="31" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
                                <GroupView class="com.horcrux.svg.GroupView" width="0" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
                                  <GroupView class="com.horcrux.svg.GroupView" width="31" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
                                    <GroupView class="com.horcrux.svg.GroupView" width="31" height="0" visibility="visible" alpha="1.0" focused="false" x="53" y="484">
                                      <RectView class="com.horcrux.svg.RectView" width="31" height="31" visibility="visible" alpha="1.0" focused="false" x="53" y="484" />
                                      <PathView class="com.horcrux.svg.PathView" width="23" height="17" visibility="visible" alpha="1.0" focused="false" x="57" y="491" />
                                    </GroupView>
                                  </GroupView>
                                </GroupView>
                              </SvgView>
                              <ReactTextView class="com.facebook.react.views.text.ReactTextView" width="468" height="51" visibility="visible" alpha="1.0" focused="false" label="Anmeldung erforderlich" x="126" y="473" text="Anmeldung erforderlich" />
                            </ReactViewGroup>
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" label="admin" x="42" y="589" id="@serverFormAuthUser/container">
                              <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" x="42" y="589" />
                              <ReactEditText class="com.facebook.react.views.textinput.ReactEditText" width="908" height="59" visibility="visible" alpha="1.0" focused="false" label="admin" x="86" y="622" text="admin" id="@serverFormAuthUser/input" />
                            </ReactViewGroup>
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" label="secret" x="42" y="778" id="@serverFormAuthPassword/container">
                              <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="126" visibility="visible" alpha="1.0" focused="false" x="42" y="778" />
                              <ReactEditText class="com.facebook.react.views.textinput.ReactEditText" width="908" height="59" visibility="visible" alpha="1.0" focused="false" label="secret" x="86" y="811" text="secret" id="@serverFormAuthPassword/input" />
                            </ReactViewGroup>
                            <ReactViewGroup class="com.facebook.react.views.view.ReactViewGroup" width="996" height="159" visibility="visible" alpha="1.0" focused="false" label="Prüfen und speichern" x="42" y="988" id="serverFormCheckAndSave">
                              <ReactTextView class="com.facebook.react.views.text.ReactTextView" width="501" height="70" visibility="visible" alpha="1.0" focused="false" label="Prüfen und speichern" x="289" y="1032" text="Prüfen und speichern" />
                            </ReactViewGroup>
                          </ReactViewGroup>
                          <ScreenStackHeaderConfig class="com.swmansion.rnscreens.ScreenStackHeaderConfig" width="1080" height="0" visibility="visible" alpha="1.0" focused="false" x="0" y="0" />
                        </Screen>
                        <AppBarLayout class="com.google.android.material.appbar.AppBarLayout" width="1080" height="0" visibility="visible" alpha="1.0" focused="false" x="0" y="0" />
                      </ScreensCoordinatorLayout>
                    </ScreenStack>
                  </SafeAreaProvider>
                </ReactSurfaceView>
              </ContentFrameLayout>
            </FitWindowsLinearLayout>
          </FrameLayout>
        </LinearLayout>
        <View class="android.view.View" width="1080" height="126" visibility="visible" alpha="1.0" focused="false" x="0" y="2274" />      
      </DecorView>
    </ViewHierarchy>

The error:

  ● Deep Linking › open server with basic auth

    Test Failed: '(an instance of android.view.View and an instance of android.widget.Checkable) and view.isChecked() matching: is <true>' doesn't match the selected view.
    Expected: (an instance of android.view.View and an instance of android.widget.Checkable) and view.isChecked() matching: is <true>
         Got: an instance of android.widget.Checkable <com.facebook.react.views.view.ReactViewGroup{f3bad65 VFE...C.. ........ 42,473-1038,526 #36}> is a com.facebook.react.views.view.ReactViewGroup
    View Details: ReactViewGroup{id=54, visibility=VISIBLE, width=996, height=53, has-focus=false, has-focusable=true, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=false, is-selected=false, layout-params=android.view.ViewGroup$LayoutParams@YYYYYY, tag=serverFormAuth, root-is-layout-requested=false, has-input-connection=false, x=42.0, y=473.0, child-count=3}

Is it a bug or am I doing something wrong?

Thank you very much for this great project!

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