# Write Component Tests for an Expo App

An agent writes React Native Testing Library tests for five untested Expo components, taking the app's Jest suite from 40 to 56 passing tests.

[Run this on Rush](https://cloud.getrush.ai/run/write-component-tests/expo/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent finds the app at the repository root (`cli/` is the generator package), reads `jest.config.js`, `jest-setup.ts` and the `setup()` helper in `src/lib/test-utils.tsx`, and compares components with the existing specs. The untouched suite passed 40 tests but already ended with "Jest did not exit one second after the test run has completed."

It picked `SettingsItem`, `EmptyList`, `PostDetailScreen`, `AddPostScreen` and `ThemeItem`. The tests render the real components and drive them with `userEvent`: loading, error and success states, validation messages that appear and clear, no request while the form is invalid, and a submit button disabled while the request is pending. Data screens render inside a `QueryClientProvider` with a stand-in axios adapter; `expo-router`, `react-native-mmkv` and `uniwind` are mocked.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Find the five components in this Expo app with the most meaningful conditional rendering or state that lacks useful tests. Locate the actual application package, not a surrounding generator package, and read its Jest setup and existing component specs. Write React Native Testing Library tests that render the real components with required application providers, interact as a user would and assert visible output or accessibility state. Use a state-owning harness for controlled inputs and cover relevant disabled behavior. Do not mock the components or change production behavior. Run focused tests and the application Jest suite without watch mode. Open a pull request explaining the selected components, behaviors covered, exact commands and any native-device limits.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

Tried on obytes/react-native-template-obytes at fd9b358: 6 files changed, 354 insertions(+), 1 deletion(-), five new `*.test.tsx` files and one line in `jest.config.js`. The agent installed pnpm with npm first. `pnpm exec jest --ci --forceExit` ended `Tests:       56 passed, 56 total` with exit 0, up from 40 on the untouched clone, and the focused run of the new suites ended `Tests:       16 passed, 16 total`. ESLint with `--fix` on the changed files reported `✖ 2 problems (0 errors, 2 warnings)`. No pull request was opened.

For the reviewer: the `jest.config.js` change adds `@dev-plugins/.*` to `transformIgnorePatterns`. Type-checking is unverified: the run's `tsc --noEmit` output was cut off, and it did not run the full `pnpm lint`. It did not assert the submit toasts or check the theme sheet closing, since in Jest the bottom sheet is always mounted.

## Run it on every night at 2 a.m. Pacific

The nightly tests automation has a `schedule` trigger on cron `0 2 * * *` in America/Los_Angeles, with this request as its prompt. Each night the agent picks the five components again.

## Why run it on Rush?

The suite looked healthy at 40 passing tests, but the run reports that any suite importing `@/lib/api` failed with `SyntaxError: Unexpected token 'export'` until `@dev-plugins/.*` joined `transformIgnorePatterns`. The run fixed that in test config only and named what Jest cannot prove here: the bottom sheet closing and the native language reload, instead of claiming device behaviour.

## Frequently asked questions

### Why ThemeItem and not LanguageItem?

Both were untested. The run reports that `changeLanguage` triggers a native reload and right-to-left layout, a poor Jest target, so it tested `ThemeItem`: opening the options, picking a theme and seeing the row's value change.

### Why does the full run use --forceExit?

The untouched clone already ended with Jest's open-handles warning. `--forceExit` lets the run finish; the run reports its new tests add no open handles, using `gcTime: Infinity` on their query clients.

## More Expo jobs

- [Add Accessibility Labels to an Expo App's Screens and Components](https://getrush.ai/run/add-accessibility-labels/expo/)
- [Add Analytics to an Expo App](https://getrush.ai/run/add-analytics/expo/)
- [Add Biometric Login to an Expo App from a Linear Issue](https://getrush.ai/run/add-biometric-auth/expo/)

## The same job on other stacks

- [Write Livewire Component Tests for a Laravel App](https://getrush.ai/run/write-component-tests/livewire/)
- [Write Component Tests for a SolidJS App](https://getrush.ai/run/write-component-tests/solidjs/)
- [Write Component Tests for a Svelte App](https://getrush.ai/run/write-component-tests/svelte/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
