MCPcopy
hub / github.com/callstack/react-native-testing-library / getByQuery

Function getByQuery

src/queries/make-queries.ts:152–170  ·  view source on GitHub ↗
(instance: TestInstance, { printElementTree = true } = {})

Source from the content-addressed store, hash-verified

150 }
151
152 function getByQuery(instance: TestInstance, { printElementTree = true } = {}) {
153 return function getFn(predicate: Predicate, options?: Options) {
154 const results = queryAllByQuery(instance)(predicate, options);
155
156 if (results.length > 1) {
157 throw new ErrorWithStack(getMultipleError(predicate, options), getFn);
158 }
159
160 if (results.length === 0) {
161 const errorMessage = formatErrorMessage(
162 getMissingError(predicate, options),
163 printElementTree,
164 );
165 throw new ErrorWithStack(errorMessage, getFn);
166 }
167
168 return results[0];
169 };
170 }
171
172 function findAllByQuery(instance: TestInstance) {
173 return function findAllFn(

Callers 1

findByQueryFunction · 0.85

Calls 3

formatErrorMessageFunction · 0.85
getMultipleErrorFunction · 0.70
getMissingErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…