Skip to content

add info about ErrorWrapper object #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
iztsv opened this issue Mar 18, 2018 · 9 comments
Closed

add info about ErrorWrapper object #476

iztsv opened this issue Mar 18, 2018 · 9 comments

Comments

@iztsv
Copy link
Contributor

iztsv commented Mar 18, 2018

What problem does this feature solve?

As I can see find method returns Wrapper object if element found or ErrorWrapper object if not element found. Both are implement BaseWrapper.

I think it will be good to add this information in order to do more clear info about returning type of find.

Also, may be create page for ErrorWrapper object.

What does the proposed API look like?

Returns: {Wrapper}

to something like

Returns: {Wrapper | ErrorWrapper}

...some notes when ErrorWrapper returned and example...
@eddyerburgh
Copy link
Member

I'm not sure there's value in telling users about the error wrapper. It's purpose is to handle cases when an element isn't found, and it has the same methods as the Wrapper.

What notes about the ErrorWrapper would you find useful?

@iztsv
Copy link
Contributor Author

iztsv commented Mar 19, 2018

@eddyerburgh thanks for the reply.

Maybe enough to add something like this notes for find method:

> Example: ...

Note: you can check that at least one element is found using `exists` method:

const div = wrapper.find('div')
expect(wrapper.exists()).toBe(true)

Because I expect that expect(wrapper.find('div')).toBe(false) if no one element is found, but it's always will be true - maybe it's my strange logic 😄

@eddyerburgh
Copy link
Member

That's a reasonable assumption, but the docs do say find returns a Wrapper object. I don't think we need to add more detail than that.

@iztsv
Copy link
Contributor Author

iztsv commented Mar 23, 2018

Thanks!

@iztsv iztsv closed this as completed Mar 23, 2018
@nidkil
Copy link

nidkil commented Jan 22, 2019

Hi guys, sorry to comment on a closed issue, but I have just run into the same issue. Calling find returns ErrorWrapper instead of the expected false. I needed to Google around to findout why. What is the harm of clarifying this in the documentation? It is not obvious that it can be queried with .exists. A short explanation explaining that if find does not find a match it returns an ErrorWrapper that can be checked with .exists?

@eddyerburgh
Copy link
Member

Ok, we could add a sentence in the find docs. Would you like to write it @nidkil ?

@tomasbjerre
Copy link
Contributor

tomasbjerre commented Aug 30, 2019

I prefer naming methods like:

  • find(x) that will search for x. It may not find anything, and it is totally expected.
  • get(x) that will get x. It will always return value of x or it will throw exception stating that x could not be found.

So I am missing the get method here.

See #1298

@scridget
Copy link

Agreee - running into this as well. exists returns true, even when the actual component isn't found.

@Robin-Hoodie
Copy link

Robin-Hoodie commented Nov 6, 2020

Testing this with @vue/[email protected] and exists() actually returns false for an ErrorWrapper component

This can also be found in the sourcecode:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants