testcafe icon indicating copy to clipboard operation
testcafe copied to clipboard

Function based Selectors should have option for specifying label

Open dantman opened this issue 1 year ago • 1 comments

What is your Scenario?

When using a function based Selector errors for non-matching elements generated by TestCafe give you no clue what the failing selector is. For example this is an issue if you use any of the selectors in @testing-library/testcafe.


   1) The specified selector does not match any element in the DOM tree.

       > | Selector([function])

This is doubly problematic if the error is triggered from a helper function that you pass the selector to. As the highlighted code will be for the helper and will not display the code you can trace the selector back to.

What are you suggesting?

The Selector() function's options should have an additional label option which can be a string or optionally a function that takes the dependencies passed to the Selector's client function.

This way libraries that create function based Selectors can also provide a label to display in errors.

What alternatives have you considered?

No response

Additional context

No response

dantman avatar Jul 07 '22 20:07 dantman

Your suggestion seems reasonable. We'll take it into account. However, we are currently focused on other features, so I cannot give you any estimates on this. If you wish, you can create a PR, which implements this enhancement.

AlexKamaev avatar Jul 11 '22 06:07 AlexKamaev

We decided to close this issue to keep our backlog in actual state. If you still need this functionality, you can create a PR that implements this enhancement.

AlexKamaev avatar Aug 22 '23 07:08 AlexKamaev