Skip to content

Commit 91453e7

Browse files
committed
docs: agents.md refactor
1 parent 250a1c6 commit 91453e7

5 files changed

Lines changed: 62 additions & 55 deletions

File tree

AGENTS.md

Lines changed: 13 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,20 @@
11
# Test Renderer for React
22

3-
## Project Overview
3+
`test-renderer` is a lightweight React 19 test renderer built on `react-reconciler`.
44

5-
**Test Renderer for React** is a lightweight, pure JavaScript testing library for React 19. It replaces the deprecated `react-test-renderer`. Built with `react-reconciler`, it outputs to a lightweight, traversable object structure (`TestInstance`) for snapshot testing and asserting component output without a browser environment (DOM) or native dependencies.
5+
Use Bun for repository scripts.
66

7-
### Key Features
7+
Core commands:
88

9-
- **React 19 Ready:** Supports modern React features, including concurrent rendering.
10-
- **Lightweight & Universal:** No DOM or native dependencies. Runs in any JavaScript environment (Node.js, Bun, etc.).
11-
- **Type-Safe:** Written in strict TypeScript.
12-
- **Snapshot Friendly:** Produces JSON output for Jest/Vitest snapshots.
9+
- `bun run build`
10+
- `bun run typecheck`
11+
- `bun run test`
12+
- `bun run validate`
1313

14-
### Architecture
14+
Project docs:
1515

16-
- **`src/index.ts`**: The public entry point that exports `createRoot` from `renderer.ts`.
17-
- **`src/renderer.ts`**: Contains the main implementation. Exports `createRoot` which initializes the custom React reconciler.
18-
- **`src/reconciler.ts`**: Implements the `react-reconciler` host config, translating React updates into operations on the internal tree.
19-
- **`src/test-instance.ts`**: Defines `TestInstance`, a wrapper around the internal fiber nodes with a DOM-like API (e.g., `children`, `props`, `parent`).
20-
- **`src/render-to-json.ts`**: Handles the serialization of `TestInstance` trees into JSON format for snapshots.
21-
22-
## Building and Running
23-
24-
The project uses **Bun** for development scripts, but you can install it via npm.
25-
26-
### Prerequisites
27-
28-
- Node.js (for consumption)
29-
- Bun (for development scripts)
30-
31-
### Key Commands
32-
33-
| Command | Description |
34-
| :--------------------- | :------------------------------------------------------------- |
35-
| `bun run build` | Builds the project using `tsup` into `dist/` (CJS and ESM). |
36-
| `bun run dev` | Runs the build in watch mode. |
37-
| `bun run test` | Runs the test suite using `jest`. |
38-
| `bun run lint` | Runs `eslint` to check code style. |
39-
| `bun run typecheck` | Runs `tsc` to verify types. |
40-
| `bun run validate` | Runs typechecking, tests, linting, and formatting in sequence. |
41-
| `bun run validate:fix` | Runs validate with auto-fix for formatting and linting issues. |
42-
43-
## Development Conventions
44-
45-
- **Language:** Strict TypeScript.
46-
- **Styling:** Code formatting is enforced by Prettier (configured via npm scripts, no explicit config file, uses defaults).
47-
- **Testing:** Unit tests are located in `src/__tests__/`. Tests use `jest` and `ts-jest`.
48-
- **Linting:** ESLint is used for static analysis.
49-
- **Git:** Commits seem to follow standard conventions (implied by `release-it`).
50-
- **Versioning:** See `docs/versioning.md` for the `1.x` compatibility-line policy for React / React Reconciler support.
51-
52-
## Directory Structure
53-
54-
- `src/`: Source code.
55-
- `__tests__/`: Unit tests.
56-
- `test-utils/`: Utilities used within project tests.
57-
- `dist/`: Compiled output (generated by build).
58-
- `.github/`: GitHub Actions workflows for CI.
59-
60-
## Rules
61-
62-
- Avoid adding unnecessary comments
16+
- [Project Overview](./docs/agents/project-overview.md)
17+
- [Architecture](./docs/agents/architecture.md)
18+
- [Development Conventions](./docs/agents/development-conventions.md)
19+
- [Commands](./docs/agents/commands.md)
20+
- [Versioning](./docs/versioning.md)

docs/agents/architecture.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Architecture
2+
3+
Key files:
4+
5+
- `src/index.ts` is the public entry point and exports `createRoot`.
6+
- `src/renderer.ts` creates renderer roots and coordinates public rendering APIs.
7+
- `src/reconciler.ts` defines the `react-reconciler` host config and tree updates.
8+
- `src/test-instance.ts` defines `TestInstance`, the main wrapper around rendered host nodes.
9+
- `src/to-json.ts` serializes rendered output into the snapshot-friendly JSON format.
10+
- `src/query-all.ts` contains tree traversal helpers used for querying.
11+
- `src/performance.ts` contains optional performance instrumentation.
12+
13+
When changing renderer behavior, start with `src/renderer.ts` and `src/reconciler.ts`.
14+
15+
When changing output shape or snapshot behavior, check `src/test-instance.ts` and `src/to-json.ts`.

docs/agents/commands.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Commands
2+
3+
Use Bun to run repository scripts.
4+
5+
- `bun run build` builds the package with `tsup` into `dist/`.
6+
- `bun run dev` runs the build in watch mode.
7+
- `bun run typecheck` runs `tsc --noEmit`.
8+
- `bun run test` runs the Jest test suite.
9+
- `bun run test:ci` runs tests with coverage.
10+
- `bun run lint` runs ESLint.
11+
- `bun run prettier` checks formatting.
12+
- `bun run prettier:fix` writes formatting changes.
13+
- `bun run validate` runs typecheck, test, lint, and formatting checks.
14+
- `bun run validate:fix` runs formatting and lint fixes, then typecheck and tests.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Development Conventions
2+
3+
- Use strict TypeScript.
4+
- Tests live in `src/__tests__/`.
5+
- Project tests use `jest` with `ts-jest`.
6+
- Linting uses ESLint.
7+
- Formatting uses Prettier through package scripts.
8+
- Avoid adding unnecessary comments.

docs/agents/project-overview.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Project Overview
2+
3+
`test-renderer` is a lightweight, JavaScript-only replacement for the deprecated `react-test-renderer`.
4+
5+
It is built on `react-reconciler` and produces a traversable object tree based on `TestInstance`, so tests can inspect rendered output without a DOM or native runtime.
6+
7+
Relevant source layout:
8+
9+
- `src/` contains the implementation.
10+
- `src/__tests__/` contains unit tests.
11+
- `src/test-utils/` contains helpers used by project tests.
12+
- `dist/` contains generated build output.

0 commit comments

Comments
 (0)