{"name":"test-renderer","version":"0.12.0","keywords":["react","react-test-renderer","testing","test-renderer","react-19","jest"],"author":{"name":"Maciej Jastrzebski","email":"mdjastrzebski@gmail.com"},"license":"MIT","_id":"test-renderer@0.12.0","maintainers":[{"name":"mdjastrzebski","email":"mdjastrzebski@gmail.com"}],"homepage":"https://github.com/mdjastrzebski/test-renderer","bugs":{"url":"https://github.com/mdjastrzebski/test-renderer/issues"},"dist":{"shasum":"6502da52dec3736b4516d61940a915b7fc39352c","tarball":"http://registry-npm.ywwl.com/test-renderer/download/test-renderer-0.12.0.tgz","fileCount":8,"integrity":"sha512-wmSBLX0Wao1TJUvhX69KHqe/O5E6/NRWHKv60Z95toXi3sIcXNCJTFB9zEnPcSdYaf45bBX03oQvVi5wc/ZkCg==","signatures":[{"sig":"MEUCIQCsV9oONSIOeh2sca4MHrUsC0A0HThUp0+WQ8kGWzL8wQIgQBiQfvPDzd7QPBw9kz7a1Vi6mrtrOnIZiUE8zBmnExw=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189647,"size":47001,"noattachment":false,"key":"/test-renderer/-/test-renderer-0.12.0.tgz"},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"b5ac5a95a98276dba067c2702b70030666dacb52","scripts":{"dev":"tsup --watch","lint":"eslint .","test":"jest","build":"tsup","release":"release-it","test:ci":"jest --coverage","prettier":"prettier --check .","validate":"bun run prettier && bun run lint && bun run typecheck && bun run test","typecheck":"tsc --noEmit","test:watch":"jest --watch","prettier:write":"prettier --write .","validate:write":"bun run prettier:write && bun run lint --fix && bun run typecheck && bun run test -u"},"_npmUser":{"name":"mdjastrzebski","email":"mdjastrzebski@gmail.com"},"repository":{"url":"git+https://github.com/mdjastrzebski/test-renderer.git","type":"git"},"_npmVersion":"10.9.2","description":"A lightweight, JavaScript-only replacement for the deprecated React Test Renderer.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"react-reconciler":"~0.31.0","@types/react-reconciler":"~0.31.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.2.0","tsup":"^8.4.0","react":"^19.0.0","eslint":"^9.21.0","ts-jest":"^29.2.6","prettier":"^3.5.2","@eslint/js":"^9.21.0","release-it":"^18.1.2","typescript":"~5.7.3","@types/jest":"^30.0.0","@types/react":"^19.0.10","@jest/globals":"^30.2.0","typescript-eslint":"^8.25.0","eslint-plugin-simple-import-sort":"^12.1.1","@release-it/conventional-changelog":"^10.0.0"},"peerDependencies":{"react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/test-renderer_0.12.0_1767779089063_0.021053025173547457","host":"s3://npm-registry-packages-npm-production"},"readme":"# Test Renderer for React\n\nA lightweight test renderer for React and a modern replacement for the deprecated React Test Renderer.\n\nThis library is used by [React Native Testing Library](https://github.com/callstack/react-native-testing-library) but should work with any React variant.\n\nIt uses [React Reconciler](https://github.com/facebook/react/tree/main/packages/react-reconciler) to build a custom renderer that operates on host elements by default, and provides escape hatches for complex use-cases. Most React Reconciler options are exposed through `RootOptions`.\n\nFor release and compatibility policy, see [docs/versioning.md](./docs/versioning.md).\n\n## Installation\n\n```bash\nyarn add -D test-renderer\n```\n\n## Getting Started\n\n```tsx\nimport { createRoot } from \"test-renderer\";\nimport { act } from \"react\";\n\ntest(\"renders a component\", async () => {\n  const renderer = createRoot();\n\n  // Use `act` in async mode to allow resolving all scheduled React updates\n  await act(async () => {\n    renderer.render(<div>Hello!</div>);\n  });\n\n  expect(renderer.container).toMatchInlineSnapshot(`\n    <>\n      <div>\n        Hello!\n      </div>\n    </>\n  `);\n});\n```\n\n## Documentation\n\n- [API Reference](./docs/api.md): full `RootOptions`, `TestInstance`, and `QueryOptions`\n- [Testing Async Code with `act`](./docs/async-act.md): resolving promises, fake timers, and avoiding leaked `act` scopes\n- [Migrating from React Test Renderer](./docs/migrating-from-react-test-renderer.md)\n- [Performance Metrics](./docs/performance-metrics.md)\n- [Versioning & React 19 Compatibility](./docs/versioning.md)\n\n## Test Output Tree\n\nInstead of producing a DOM tree or a native view hierarchy, the renderer builds an in-memory **Test Output Tree**:\n\n- Composed of **`TestNode`s**, where each node is either:\n  - A **`TestInstance`**: represents a host element such as `div` or `View`\n  - A plain **`string`**: represents a text node\n- The root is accessible via `root.container`, a `TestInstance` whose `type` is an empty string\n- `TestInstance` nodes are traversable and queryable; see the [`TestInstance`](./docs/api.md#testinstance) API\n\n## JSON Output Tree\n\nCalling `toJSON()` on a `TestInstance` produces a **JSON Output Tree**, a static, plain-object snapshot of the Test Output Tree at that point in time:\n\n- Composed of **`JsonNode`s**, where each node is either:\n  - A **`JsonElement`**: a plain object with `type`, `props`, and `children`\n  - A plain **`string`**: a text node\n- Contains no live references, making it safe to serialize\n- Ideal for snapshot testing\n\n## API Reference\n\n### `createRoot(options?)`\n\nCreates a new test renderer root instance.\n\n**Parameters:**\n\n- `options` (optional): Configuration options for the renderer. See [`RootOptions`](#rootoptions) below.\n\n**Returns:** A `Root` object with the following properties:\n\n- `render(element: ReactElement)`: Renders a React element into the root. Fragments are supported. Non-element root values such as strings or `null` are not supported. Must be called within `act()`.\n- `unmount()`: Unmounts the root and cleans up. Must be called within `act()`.\n- `container`: A `TestInstance` wrapper that contains the rendered element(s). Use this to query and inspect the rendered tree.\n\n**Example:**\n\n```tsx\nconst renderer = createRoot();\nawait act(async () => {\n  renderer.render(<div>Hello!</div>);\n});\n```\n\n### `RootOptions`\n\nOptional configuration passed to `createRoot`. Common options:\n\n- `textComponentTypes` / `publicTextComponentTypes`: Host component types allowed to contain text nodes (useful for simulating React Native's text rendering rules).\n- `isStrictMode`: Enable React Strict Mode.\n- `identifierPrefix`: Prefix for IDs generated by `useId()`.\n- `onCaughtError` / `onUncaughtError` / `onRecoverableError`: Error-handling callbacks.\n\nThe full options table, along with the `TestInstance` and `QueryOptions` APIs, is in the [API Reference](./docs/api.md).\n\n## License\n\nMIT\n","publish_time":1767779089215,"_cnpm_publish_time":1767779089215,"dist-tags":{"latest":"1.3.1"}}