spectator icon indicating copy to clipboard operation
spectator copied to clipboard

Improve error message for not visible elements in tests

Open IanIsFluent opened this issue 4 years ago • 3 comments

I'm submitting a...

[x] Feature request

Current behavior

When an element that you expect to be visible is not, the error message is Expected element to be visible.

Expected behavior

The error message would include the matcher used to try to find the element.

Minimal reproduction of the problem with instructions

For bug reports please provide the STEPS TO REPRODUCE and if possible a MINIMAL DEMO of the problem via https://stackblitz.com or similar (you can use this template as a starting point: https://bit.ly/2zme3bj).

What is the motivation / use case for changing the behavior?

This would make it clearer quicker why a test had failed, easing mental load when trying to fix it (the line number is right there, so that's cool - it'd just be even nicer.

IanIsFluent avatar Dec 03 '20 06:12 IanIsFluent

You're welcome to submit a PR.

NetanelBasal avatar Dec 04 '20 06:12 NetanelBasal

You're welcome to submit a PR.

Do you know what would be a good approach to get from the matcher code back to the selector info? 🤔

IanIsFluent avatar Dec 04 '20 06:12 IanIsFluent

I can't think of a way to keep a reference to the selector info without changing the return type of the query to include it - so its accessible to the matchers - currently I think the query returns a plain Element. So I'd need to start using something like ElementWithSelector extends Element, right?

IanIsFluent avatar Dec 08 '20 06:12 IanIsFluent