MCPcopy Index your code
hub / github.com/callstack/react-native-testing-library / queryByQuery

Function queryByQuery

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

Source from the content-addressed store, hash-verified

131 }
132
133 function queryByQuery(instance: TestInstance, { printElementTree = true } = {}) {
134 return function singleQueryFn(predicate: Predicate, options?: Options) {
135 const results = queryAllByQuery(instance)(predicate, options);
136
137 if (results.length > 1) {
138 throw new ErrorWithStack(
139 formatErrorMessage(getMultipleError(predicate, options), printElementTree),
140 singleQueryFn,
141 );
142 }
143
144 if (results.length === 0) {
145 return null;
146 }
147
148 return results[0];
149 };
150 }
151
152 function getByQuery(instance: TestInstance, { printElementTree = true } = {}) {
153 return function getFn(predicate: Predicate, options?: Options) {

Callers

nothing calls this directly

Calls 2

formatErrorMessageFunction · 0.85
getMultipleErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…