---
title: Coding agents
description: >-
  Rules and the CI contract for Cursor, Claude, or Codex setting up
  react-native-coverage. Install steps live on App developers.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://docs.page/invertase/react-native-coverage/llms.txt
> Use this file to discover all available pages before exploring further.

## Prompt

Give your agent one line. It reads [App developers](/app-developers), the same page a person uses to get started:

```txt
Read https://docs.page/invertase/react-native-coverage/app-developers.md, and set up react-native-coverage in this project.
```

Every page on this site is also available as Markdown by adding `.md` to its URL, and the site publishes an [`llms.txt`](https://docs.page/invertase/react-native-coverage/llms.txt).

## Rules

<Warning>
  `react-native-coverage` goes in a [dedicated test app](/coverage#dedicated-test-app) only. Never add it to the shipping app's `package.json` file. Autolinking scans dependencies, so `devDependencies` does not keep the TurboModule out.
</Warning>

- Use the New Architecture only. Do not write old-architecture bridging shims.
- Do not edit the `Podfile` with a regular expression to add LLVM flags. Use the CocoaPods helper, `apply_post_install!` from the `cocoapods/coverage_post_install.rb` file. Under Expo keep `forceDynamicFrameworks: false`. Only on a React Native CLI app whose React builds as dynamic frameworks, set it `true`.
- Put the Android `.ec` file under the app build directory. `rn-coverage android pull` stages it where JaCoCo's `fileTree` includes it. Pulling only into the `artifacts/` directory leaves `jacocoTestReport` empty.
- Pin GitHub Actions by full commit SHA.

## CI contract

The pipeline must not pass with empty native coverage. The sequence is:

<Steps>
  <Step title="Run the suite">
    Launch the test app and run the suite. When you also want JavaScript coverage, start Metro with `RN_COVERAGE_JS=1`.
  </Step>
  <Step title="Flush">
    When the suite ends, call `Coverage.flush()`.
  </Step>
  <Step title="Pull and report">
    ```sh
    rn-coverage android pull && rn-coverage android report
    rn-coverage ios pull --device UDID
    rn-coverage ios export --derived-data DERIVED_DATA_PATH
    rn-coverage ios report --derived-data DERIVED_DATA_PATH
    ```
  </Step>
  <Step title="Assert">
    ```sh
    rn-coverage assert
    ```
  </Step>
</Steps>

### Exit codes

`rn-coverage assert` uses these exit codes.

| Code | Meaning |
|------|---------|
| 0 | Success. With `--no-strict`, an empty report also exits 0 with a warning. |
| 1 | Error: bad invocation or a tool failure. |
| 2 | No hits, or a report file is missing, in strict mode. |

<Warning>
  Exit 2 is a failure to fix, never one to suppress. Do not switch CI to `--no-strict` to pass the job. A passing job with no native hits means coverage failed without failing the job.
</Warning>

Set which paths and packages must have hits with `assert.lcovPathIncludes` and `assert.jacocoPackageIncludes` on [Configuration](/reference/config). For more information about fixing an exit 2, see [Empty or missing coverage](/troubleshooting/empty-coverage).

## Check the result

The working example is this repository. Its [Codecov dashboard](https://app.codecov.io/gh/invertase/react-native-coverage) carries this repository's **matrix** flags — [`e2e-ios-dynamic`](https://app.codecov.io/gh/invertase/react-native-coverage/flags/e2e-ios-dynamic), [`e2e-ios-static`](https://app.codecov.io/gh/invertase/react-native-coverage/flags/e2e-ios-static), and [`e2e-android`](https://app.codecov.io/gh/invertase/react-native-coverage/flags/e2e-android) — with hits from iOS Simulator and Android emulator runs. A single consumer test app usually uses `e2e-ios` / `e2e-android` / `e2e-js` instead (see [App developers](/app-developers#optional-upload-to-codecov)). Either way: one flag per platform cell, each with non-zero hits.

<CardGroup cols={2}>
  <Card title="CLI" icon="terminal" href="/reference/cli">
    Commands, flags, and the strict and assert contract in full.
  </Card>
  <Card title="Configuration" icon="sliders" href="/reference/config">
    The `assert.*` matchers and default report paths.
  </Card>
</CardGroup>
