|
1 | 1 | # Test Renderer for React |
2 | 2 |
|
3 | | -## Project Overview |
| 3 | +`test-renderer` is a lightweight React 19 test renderer built on `react-reconciler`. |
4 | 4 |
|
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. |
6 | 6 |
|
7 | | -### Key Features |
| 7 | +Core commands: |
8 | 8 |
|
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` |
13 | 13 |
|
14 | | -### Architecture |
| 14 | +Project docs: |
15 | 15 |
|
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) |
0 commit comments