MCPcopy
hub / github.com/testing-library/dom-testing-library / makeGetAllQuery

Function makeGetAllQuery

src/query-helpers.ts:101–116  ·  view source on GitHub ↗
(
  allQuery: (container: HTMLElement, ...args: Arguments) => HTMLElement[],
  getMissingError: GetErrorFunction<Arguments>,
)

Source from the content-addressed store, hash-verified

99// this accepts a query function and returns a function which throws an error
100// if an empty list of elements is returned
101function makeGetAllQuery<Arguments extends unknown[]>(
102 allQuery: (container: HTMLElement, ...args: Arguments) => HTMLElement[],
103 getMissingError: GetErrorFunction<Arguments>,
104) {
105 return (container: HTMLElement, ...args: Arguments) => {
106 const els = allQuery(container, ...args)
107 if (!els.length) {
108 throw getConfig().getElementError(
109 getMissingError(container, ...args),
110 container,
111 )
112 }
113
114 return els
115 }
116}
117
118// this accepts a getter query function and returns a function which calls
119// waitFor and passing a function which invokes the getter.

Callers 1

buildQueriesFunction · 0.85

Calls 2

getConfigFunction · 0.90
getMissingErrorFunction · 0.50

Tested by

no test coverage detected