Skip to content

Latest commit

 

History

History
96 lines (69 loc) · 4.55 KB

File metadata and controls

96 lines (69 loc) · 4.55 KB

Code Assistant Context

This document provides context for the any code assistant to understand the @testing-library/react-native project.

Project Overview

@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.

Project Guidelines

  • 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

Building and Running

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 on src)
  • 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)

Development Conventions

  • Code Style:

    • Linting: ESLint is configured with @callstack/eslint-config and typescript-eslint. It enforces strict rules, including no-console and consistent type imports.
    • Formatting: Prettier is used for code formatting (single quotes, trailing commas).
    • Imports: Sorted using eslint-plugin-simple-import-sort.
  • Testing:

    • Framework: Jest with react-native preset.
    • Location: Tests are located within src, typically co-located in __tests__ directories.
    • Setup: jest-setup.ts configures the test environment. src/index.ts automatically configures cleanup after each test unless skipped.
    • Coverage: Collected from src, excluding tests.
    • Organization: Use describe to group test by theme. Avoid putting all tests in the same describe block. Avoid describe nesting. Avoid describe with only single test, make that test top-level. Prefere test over it.
  • 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.
  • File Structure:

    • src/: Source code.
    • src/pure.ts: Core logic without side effects (no auto-cleanup).
    • src/index.ts: Main entry point, re-exports pure and adds side effects (auto-cleanup).
    • examples/: Example React Native applications using the library.
    • website/: Documentation website.

<skills_system priority="1">

Available Skills

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>