(instance: TestInstance, { printElementTree = true } = {})
| 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( |
no test coverage detected
searching dependent graphs…