This document provides context for the any code assistant to understand the @testing-library/react-native project.
@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.
- Core Principle: "The more your tests resemble the way your software is used, the more confidence they can give you."
- Tech Stack: TypeScript, React Native, Jest.
- Architecture: The library simulates the React Native runtime on top of
test-renderer.
- Small API surface
- Expose all features of the underlying platform (react, react-reconciler) for Testing Libraries to use
- Render host elements only, yet provide escape hatches to fibers when needed
The project uses yarn for dependency management and script execution.
- Installation:
yarn install - Run Tests:
yarn test(Runs Jest) - Run Tests (CI):
yarn test:ci(Runs Jest with worker limits) - Lint Code:
yarn lint(Runs ESLint onsrc) - Type Check:
yarn typecheck(Runs TypeScript compiler) - Format Check:
yarn prettier - Validate All:
yarn validate(Runs Prettier, ESLint, Typecheck, and Tests in sequence) - Build Project:
yarn build(Cleans, builds JS with Babel, and builds TS types)
-
Code Style:
- Linting: ESLint is configured with
@callstack/eslint-configandtypescript-eslint. It enforces strict rules, includingno-consoleand consistent type imports. - Formatting: Prettier is used for code formatting (single quotes, trailing commas).
- Imports: Sorted using
eslint-plugin-simple-import-sort.
- Linting: ESLint is configured with
-
Testing:
- Framework: Jest with
react-nativepreset. - Location: Tests are located within
src, typically co-located in__tests__directories. - Setup:
jest-setup.tsconfigures the test environment.src/index.tsautomatically configures cleanup after each test unless skipped. - Coverage: Collected from
src, excluding tests. - Organization: Use
describeto group test by theme. Avoid putting all tests in the samedescribeblock. Avoiddescribenesting. Avoiddescribewith only single test, make that test top-level. Preferetestoverit.
- Framework: Jest with
-
Commits & Releases:
- Commits: Follow the Conventional Commits specification (e.g.,
fix:,feat:,chore:). This is enforced and used for changelog generation. - Releases: Managed via
release-it.
- Commits: Follow the Conventional Commits specification (e.g.,
-
File Structure:
src/: Source code.src/pure.ts: Core logic without side effects (no auto-cleanup).src/index.ts: Main entry point, re-exportspureand adds side effects (auto-cleanup).examples/: Example React Native applications using the library.website/: Documentation website.
<skills_system priority="1">
When users ask you to perform tasks, check if any of the available skills below can help complete the task more effectively. Skills provide specialized capabilities and domain knowledge.How to use skills:
- Invoke: Bash("openskills read ")
- The skill content will load with detailed instructions on how to complete the task
- Base directory provided in output for resolving bundled resources (references/, scripts/, assets/)
Usage notes:
- Only use skills listed in <available_skills> below
- Do not invoke a skill that is already loaded in your context
- Each skill invocation is stateless
<available_skills>
code-review Master effective code review practices to provide constructive feedback, catch bugs early, and foster knowledge sharing while maintaining team morale. Use when reviewing pull requests, establishing review standards, or mentoring developers. project doc-coauthoring Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks. project</available_skills>
</skills_system>