Files
agentic-dev/docs/library-decisions/2026-05-14-@testing-library/jest-dom.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/jest-dom"
version: "^6.5.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/jest-dom license
- npm view @testing-library/jest-dom version
- pnpm audit --audit-level=moderate
accepted-cves: []
---
## Filter: license
<!-- Result: MIT -->
`npm view @testing-library/jest-dom license` returns `MIT`. MIT is on the allowlist.
## Filter: types
<!-- Result: native -->
`@testing-library/jest-dom` ships its own TypeScript declaration files that extend the vitest/jest `expect` matchers. No separate `@types/` package is needed.
## Filter: maintenance
<!-- Result: active -->
Actively maintained by the Testing Library organization. The 6.x line is the current major. Regular releases tracking vitest and jest compatibility.
## Filter: boundary-fit
<!-- Result: pass -->
`@testing-library/jest-dom` is a dependency of `@repo/core-testing`, which is the workspace's shared testing infrastructure package. Custom DOM matchers (`toBeInTheDocument`, `toHaveTextContent`, etc.) are set up in `core-testing`'s setup file and available to all feature test suites via the `core-testing` dependency. This is the correct placement.
## Filter: shadow-check
<!-- Result: pass -->
`@testing-library/jest-dom` is the sole custom DOM matcher extension in the workspace. No competing matcher library is present.
## Filter: eu-residency
<!-- Result: n/a -->
`@testing-library/jest-dom` 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/jest-dom` at the time of this trace.
## Filter: named-consumer
<!-- Result: pass -->
`@repo/core-testing` uses `@testing-library/jest-dom` to set up custom DOM assertion matchers. Feature packages that render React components in tests use these matchers via `core-testing`. Named, non-hypothetical consumer exists today.
## Prompt: replaces
`@testing-library/jest-dom` extends vitest's `expect` with semantic DOM matchers, replacing brittle assertion patterns like `expect(el.innerHTML).toContain('text')` with `expect(el).toHaveTextContent('text')`.
## Prompt: migration-cost-out
Low. `@testing-library/jest-dom` is configured in one setup file in `@repo/core-testing`. Removing it requires updating that setup and replacing any DOM-specific matchers in test files with lower-level assertions.
## Prompt: alternatives-considered
1. **Plain vitest `expect` matchers only** — Viable but produces less readable test assertions for DOM state; `toBeInTheDocument()` is significantly clearer than checking element existence manually.
2. **`@vitest/ui` accessibility assertions** — Narrower scope; `@testing-library/jest-dom` covers the full semantic DOM assertion surface.