Closed
Description
What problem does this feature solve?
Sometimes you "look for something" and sometimes you "get something". If you look for something, it may not exists. If you get something, it is an error if it does not exist.
In my test cases I want to use a get method on the wrapper. And get a clear error describing that what I was looking for cannot be found.
What does the proposed API look like?
In Wrapper.js
/**
* Gets first node in tree of the current wrapper that
* matches the provided selector.
*/
get(rawSelector: Selector): Wrapper {
const found = find(rawSelector)
if (found instanceof ErrorWrapper) {
throw new Error(`Unable to find ${rawSelector} within: ${this.html()}`)
}
return found
}