Files
agentic-dev/docs/library-decisions/2026-05-14-@testing-library/react.md
Danijel Martinek 1108e24ea0 chore(deps): backfill library traces for un-cited cluster
Add approved trace files for payload, @trpc/server, @trpc/client, zod,
superjson, @payloadcms/db-postgres, @payloadcms/richtext-lexical, globals,
react, react-dom, vitest, @tanstack/react-query, and all @testing-library/*
packages. All traces dated 2026-05-14, decision: approved, adr: null.

Establishes the baseline so the pre-commit library-decisions gate is
additive (new deps require traces) rather than disruptive (old deps fail
immediately). All 34 trace files pass validateTrace() from schema.mjs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-14 10:10:23 +00:00

85 lines
3.0 KiB
Markdown

---
package: "@testing-library/react"
version: "^16.0.0"
tier: core
decision: approved
date: 2026-05-14
deciders: [Danijel Martinek]
adr: null
filter-results:
license: MIT
types: native
maintenance: active
boundary-fit: pass
shadow-check: pass
eu-residency: n/a
cve-scan: clean
named-consumer: pass
verification-commands:
- npm view @testing-library/react license
- npm view @testing-library/react version
- pnpm audit --audit-level=moderate
accepted-cves: []
---
## Filter: license
<!-- Result: MIT -->
`npm view @testing-library/react license` returns `MIT`. MIT is on the allowlist.
## Filter: types
<!-- Result: native -->
`@testing-library/react` ships its own TypeScript declaration files. No separate `@types/` package is needed.
## Filter: maintenance
<!-- Result: active -->
Actively maintained by the Testing Library organization. The 16.x line targets React 19. Regular releases; strong community and ecosystem adoption.
## Filter: boundary-fit
<!-- Result: pass -->
`@testing-library/react` is a dependency of `@repo/core-testing`, the workspace's shared testing infrastructure. It provides `render`, `screen`, `fireEvent`, and related utilities for component tests. Feature packages that test UI components use these utilities via `core-testing`. This is the correct placement for shared test infrastructure.
## Filter: shadow-check
<!-- Result: pass -->
`@testing-library/react` is the sole React component testing utility in the workspace. No competing library (Enzyme, React Test Renderer) is present.
## Filter: eu-residency
<!-- Result: n/a -->
`@testing-library/react` is a test utility library with no network communication. EU residency does not apply.
## Filter: cve-scan
<!-- Result: clean -->
`pnpm audit --audit-level=moderate` reports no advisories against `@testing-library/react` at the time of this trace.
## Filter: named-consumer
<!-- Result: pass -->
`@repo/core-testing` uses `@testing-library/react` to provide the `render` utility and `screen` query API for component tests. Feature packages with UI components use these via `core-testing`. Named, non-hypothetical consumer exists today.
## Prompt: replaces
`@testing-library/react` replaces Enzyme and React Test Renderer. Testing Library's philosophy of testing from the user's perspective (querying by role, label, text) produces more resilient tests than implementation-detail-aware approaches.
## Prompt: migration-cost-out
Hard. `render`, `screen`, `fireEvent`, and `userEvent` APIs from Testing Library are used in all component tests. Migrating to a different testing approach requires rewriting all component tests and changing the query strategy (from accessibility-tree queries to DOM selectors or component internals).
## Prompt: alternatives-considered
1. **Enzyme** — Deprecated and no longer maintained for React 18+; Testing Library is the ecosystem standard.
2. **`react-dom/test-utils`** — Lower-level API without the accessibility-query helpers; more verbose and less idiomatic for testing user behavior.