{"name":"test-renderer","version":"1.2.0","keywords":["jest","react","react-19","react-test-renderer","test-renderer","testing"],"author":{"name":"Maciej Jastrzebski","email":"mdjastrzebski@gmail.com"},"license":"MIT","_id":"test-renderer@1.2.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":"b106039bd4df8a40ea3de3718a6f346df184957b","tarball":"http://registry-npm.ywwl.com/test-renderer/download/test-renderer-1.2.0.tgz","fileCount":7,"integrity":"sha512-JYiEGbgBGtmHAWX8Kf99gGRL1HtjcRVHLrmJNTZL4vFs9XrnWcuL45Iszw/pO4094+JR7havSrN+ds6YTOpSQA==","signatures":[{"sig":"MEUCIHfdYywVeeESgo61u1+WHksJoIbiGyYBmYlTx49Tdn/OAiEA705FVhSZtjTWLpuN9X98wqZRkcMqrEqDgKCEc6rHgQ8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189704,"size":41268,"noattachment":false,"key":"/test-renderer/-/test-renderer-1.2.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"},"./package.json":{"default":"./package.json"}},"gitHead":"17874e2ca312d50534013537eac3114a4fb8b1ee","scripts":{"dev":"tsdown --watch","lint":"eslint .","test":"jest","build":"tsdown","format":"oxfmt --check .","release":"release-it","test:ci":"jest --coverage","validate":"bun run typecheck && bun run test && bun run lint && bun run format","typecheck":"tsc --noEmit","format:fix":"oxfmt .","test:watch":"jest --watch","format:check":"oxfmt --check .","validate:fix":"bun run format:fix && bun run lint --fix && bun run typecheck && bun run test -u","check:react-release-guard":"node scripts/check-react-release-guard.mjs"},"_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 test renderer for React and a modern replacement for the deprecated React Test Renderer.","directories":{},"_nodeVersion":"22.17.1","dependencies":{"react-reconciler":"~0.33.0","@types/react-reconciler":"~0.33.0"},"testRenderer":{"supportedReactRange":">=19.0.0 <19.3.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^30.3.0","oxfmt":"^0.44.0","react":"^19.2.5","eslint":"^10.2.0","tsdown":"^0.21.7","ts-jest":"^29.4.9","@eslint/js":"^10.0.1","release-it":"^19.2.4","typescript":"~6.0.2","@types/jest":"^30.0.0","@types/node":"^25.6.0","@types/react":"^19.2.14","@jest/globals":"^30.3.0","typescript-eslint":"^8.58.1","eslint-plugin-simple-import-sort":"^13.0.0","@release-it/conventional-changelog":"^10.0.6"},"peerDependencies":{"react":"^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/test-renderer_1.2.0_1776375789280_0.8784966283455733","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":1776375789430,"_cnpm_publish_time":1776375789430,"dist-tags":{"latest":"1.3.1"}}