Skip to content
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

Error message when no elements match an interactors's selector is not as helpful as it could be #180

Open
cowboyd opened this issue Feb 3, 2022 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@cowboyd
Copy link
Member

cowboyd commented Feb 3, 2022

If you have an interactor like:

export default HTML.extend("MyComponent")
  .selector('.my-class')

and when you try and use it

await MyComponent("Hello").exists();

but there is no element matching .my-class in the DOM, you will see an error like this:

NoSuchElementError: cannot find MyComponent  "Hello"

The specific meaning of this error is that no elements matched the selector, and therefore no attempt could even be made to match the locator and filters.

This could mean two things. Either, there is a bug in your app and the desired element is not appearing at all, or there is a bug in your interactor selector. We diagnose the first case accurately, but if second case holds and there is a bug in your interactor selector we don't give direct feedback that there were zero matching candidates. This false negative can be misleading. We should try and at least present the developer with the possibility that their selector is wrong. Possibilities include:

NoSuchElement: no elements found matching selector for MyComponent "Hello"
NoSuchElement: selector `.my-class` did not find any elements for MyComponent "Hello"

The only problem with ☝🏻 is that not all selectors are short and sweet:

NoSuchElement: selector did not find any elements for MyComponent "Hello"
selector: '[^my-class-pretty-gnarly*]'

Finding "adjacent" selectors that are similar would be awesome too, but don't know how to even begin to look at that.

@cowboyd cowboyd added enhancement New feature or request good first issue Good for newcomers labels Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant