|
| 1 | +# Code Assistant Context |
| 2 | + |
| 3 | +This document provides context for the any code assistant to understand the `@testing-library/react-native` project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`@testing-library/react-native` (RNTL) provides a set of utilities for testing React Native components. It is designed to facilitate writing tests that resemble how users interact with the application, avoiding implementation details. |
| 8 | + |
| 9 | +- **Core Principle:** "The more your tests resemble the way your software is used, the more confidence they can give you." |
| 10 | +- **Tech Stack:** TypeScript, React Native, Jest. |
| 11 | +- **Architecture:** The library simulates the React Native runtime on top of `universal-test-renderer`. |
| 12 | + |
| 13 | +## Building and Running |
| 14 | + |
| 15 | +The project uses `yarn` for dependency management and script execution. |
| 16 | + |
| 17 | +- **Installation:** `yarn install` |
| 18 | +- **Run Tests:** `yarn test` (Runs Jest) |
| 19 | +- **Run Tests (CI):** `yarn test:ci` (Runs Jest with worker limits) |
| 20 | +- **Lint Code:** `yarn lint` (Runs ESLint on `src`) |
| 21 | +- **Type Check:** `yarn typecheck` (Runs TypeScript compiler) |
| 22 | +- **Format Check:** `yarn prettier` |
| 23 | +- **Validate All:** `yarn validate` (Runs Prettier, ESLint, Typecheck, and Tests in sequence) |
| 24 | +- **Build Project:** `yarn build` (Cleans, builds JS with Babel, builds TS types, and copies Flow types) |
| 25 | + |
| 26 | +## Development Conventions |
| 27 | + |
| 28 | +- **Code Style:** |
| 29 | + - **Linting:** ESLint is configured with `@callstack/eslint-config` and `typescript-eslint`. It enforces strict rules, including `no-console` and consistent type imports. |
| 30 | + - **Formatting:** Prettier is used for code formatting (single quotes, trailing commas). |
| 31 | + - **Imports:** Sorted using `eslint-plugin-simple-import-sort`. |
| 32 | + |
| 33 | +- **Testing:** |
| 34 | + - **Framework:** Jest with `react-native` preset. |
| 35 | + - **Location:** Tests are located within `src`, typically co-located in `__tests__` directories. |
| 36 | + - **Setup:** `jest-setup.ts` configures the test environment. `src/index.ts` automatically configures cleanup after each test unless skipped. |
| 37 | + - **Coverage:** Collected from `src`, excluding tests. |
| 38 | + |
| 39 | +- **Commits & Releases:** |
| 40 | + - **Commits:** Follow the **Conventional Commits** specification (e.g., `fix:`, `feat:`, `chore:`). This is enforced and used for changelog generation. |
| 41 | + - **Releases:** Managed via `release-it`. |
| 42 | + |
| 43 | +- **File Structure:** |
| 44 | + - `src/`: Source code. |
| 45 | + - `src/pure.ts`: Core logic without side effects (no auto-cleanup). |
| 46 | + - `src/index.ts`: Main entry point, re-exports `pure` and adds side effects (auto-cleanup). |
| 47 | + - `examples/`: Example React Native applications using the library. |
| 48 | + - `website/`: Documentation website. |
0 commit comments