waitUntil, if given should return custom error message when condition returns always false#10535
Conversation
christian-bromann
left a comment
There was a problem hiding this comment.
I think the best solution is to do the following change in line 80 of packages/webdriverio/src/utils/Timer.ts#L80:
- return this._checkCondition(new Error('return value was never truthy'))
+ return this._checkCondition(new Error(TIMEOUT_ERROR))Then the right timeout message should be thrown as defined in line 50
|
updated as per your comment. Could you please verify now? |
|
@rashiq231 I think we need to update one more unit test: |
|
okay... I will update the test case for Timer. |
|
The docs implicitly say:
So there is no reason to have an error message stating the obvious and use the timeout error because that is what happens at the end: the timer times out because no truthy value was returned. |
|
Congratulations on your first WebdriverIO contribution! This project can't live without the participation of the community. We would love to see more from you, so let us know if we can help to find interesting areas for you to contribute to. Join our Discord channel and reach out to us. We appreciate you 🙏 ❤️ |
|
@christian-bromann , Thank you for your help and support :) |
Proposed changes
waitUntil should return a custom error message if given, else should return a default error message when the condition always returns false ( not resolving to falsy)
//: # (Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.)
This change is to resolve an issue reported in the #10495 , where waitUntil doesn't throw a custom error message if given.
With this change, we check for a condition if the given function always returns falsy and has a custom error message.
Types of changes
Checklist
Further comments
Reviewers: @webdriverio/project-committers