Skip to Content
ARCUI

Testing

Test ARCUI-dependent application code through the public testing entry point and semantic state.

ARCUI testing helpers intentionally live outside the production root entry point.

ARCUIMock

import { ARCUIMock } from "react-native-arc-ui/testing";

render(
  <ARCUIMock>
    <ComponentUnderTest />
  </ARCUIMock>,
);

ARCUIMock provides ARCUI context without requiring consumer tests to import private providers.

It accepts supported token and string overrides:

<ARCUIMock
  strings={{ headerBackAccessibilityLabel: "Back" }}
  tokens={tokens}
>
  <ComponentUnderTest />
</ARCUIMock>

Test semantics, not internals

Prefer assertions around:

  • visible content;
  • accessible role/name/state;
  • controlled callback requests;
  • disabled/inactive behavior;
  • selection ownership;
  • validation/error content;
  • overlay lifecycle visible to the user;
  • final committed Slider values.

Avoid assertions against ARCUI private component structure or private SharedValues.

Controlled components

Callbacks request state changes. The test harness must update the controlled prop if the test expects the rendered semantic state to change.

function Harness() {
  const [checked, setChecked] = useState(false);

  return (
    <Checkbox checked={checked} onCheckedChange={setChecked}>
      Option
    </Checkbox>
  );
}

Animations

Prefer testing final semantic/visible behavior rather than intermediate Reanimated frames unless the application itself owns an animation contract.

Overlays

Use public APIs:

  • drive Modal visible from test state;
  • call showDialog / hideDialog;
  • call showToast / hideToast.

Do not mount private Host components directly.

Because overlay content may be rehosted, query by semantic content or documented test IDs rather than assuming local wrapper ancestry.

Package boundary

runtime -> react-native-arc-ui
testing -> react-native-arc-ui/testing

Do not deep-import test helpers from dist or src.

Component-specific test IDs

Reusable test IDs exposed by an ARCUI component are documented on that component page rather than duplicated here. This keeps exact suffixes and semantics next to the component behavior they belong to.

For example, use the component documentation when you need the supported test surface for Input, Slider, Modal, or Dialog.

Accessibility-first queries

When your test stack supports them, prefer role/name/state queries over implementation selectors. testID remains useful for cases where a component intentionally exposes a stable automation hook, but it should not replace semantic assertions when the user-facing contract is accessibility state or visible content.

On this page