CodeVetter · Repo Unpack · System map
testing-library/dom-testing-library
The runtime is an importable DOM utility library with a named-export entrypoint and eight query families. Browser objects belong to the consumer; the implementation binds queries to containers and obtains windows from supplied nodes. Configuration and retry bookkeeping live in memory, while diagnostics provide a limited Node filesystem integration. Distribution and CI are defined by npm metadata, inherited kcd-scripts configuration, and GitHub Actions.
- package.json directs CommonJS consumers to dist/index.js, ESM consumers to dist/@testing-library/dom.esm.js, UMD consumers to dist/@testing-library/dom.umd.js, and TypeScript consumers to types/index.d.ts; Node >=18 is declared.
- src/index.js exports queries, asynchronous utilities, events, screen, diagnostics, configuration, and suggestions; within aliases getQueriesForElement, and queries/queryHelpers are also namespace exports.
- src/queries/index.ts aggregates LabelText, PlaceholderText, Text, DisplayValue, AltText, Title, Role, and TestId; buildQueries supplies shared variant construction for most families.
- screen binds document.body during module evaluation when available; explicit container APIs use getQueriesForElement, and event/wait helpers resolve the supplied node's owning window.
- The inspected state owners are module-level configuration, per-wait promise/timer/observer bookkeeping, and a per-role-query WeakMap; these paths keep state in memory rather than implementing durable storage.
- Role semantics integrate aria-query and dom-accessibility-api; formatting uses pretty-format, playground URL generation uses lz-string, and Node code frames dynamically load fs, @babel/code-frame, and picocolors.
- npm scripts delegate build, lint, tests, validation, and typechecking to kcd-scripts; build excludes test directories and performs a second bundled build, while Rollup explicitly requires named exports.
- GitHub validation targets Node 18 and 24; an upstream push can trigger a dependent production-environment build and semantic release, while a separate workflow runs an alt-text bot on supported community events.