-
Notifications
You must be signed in to change notification settings - Fork 90
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
Better errors from visitable #640
Conversation
This adds the actual error message from Ember's router to the (too generic) message from `visitable`. This is especially important when your test needs to know what kind of error was triggered. For example some tests might want to handle `TransitionAborted` errors differently, see emberjs/ember-test-helpers#332 (comment).
Hey @simonihmig 👋 Thanks! I think I'm not a fan to add external error messages into the page object error messages at the first place. This may be a breaking change for some test suites if we merge it as is. And this can break test suites later, when someone upgrades the I think a good enough tradeoff could be to keep the original error in the |
Ok I think I overrated the breaking nature of this change a bit. But I still feel like the |
No worries! Normally I wouldn't think of the error message as something covered by the public API contract to be always the same. But actually, the changes in ecpo v2 were of a breaking nature to us because of this, as we had some checks like I agree that we should make use of However, I am still wondering if we should also update the message itself? You can only make use of But I'll leave that up to you to decide. My primary use case of being able to detect |
I think you are right. Let's do it! As a side note, I think it does also make sense to express the |
I just pushed this commit, which tries to implement the suggestion. However, there is a bit still left for discussion, because I realized that the error rethrown from the visitable helper is actually not the one received by the user, as it is catched and rethrown again by the "better-errors" functionality. And that already has opinions about |
Oh.. yes, what you say makes sense. I didn't expect the existing |
...under the `cause.error`
in the `visitable` error instance
@simonihmig please take a look simonihmig#1 |
Preserve original error instance
Thanks @ro0gr, merged it, so this PR should be good to go now I hope! |
@@ -1,6 +1,7 @@ | |||
{ | |||
"extends": "@tsconfig/ember/tsconfig.json", | |||
"compilerOptions": { | |||
"target": "es2022", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering if this was needed for some reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, right... this was needed to make TS understand that Error#cause
is a thing. Was getting type errors without it when trying to access .cause
.
Awesome. I've just left one minor question. Going to publish this tonight. |
What is the question? 😄 |
Hey, I've just released this https://github.com/san650/ember-cli-page-object/releases/tag/v2.3.0 |
This adds the actual error message from Ember's router to the (too generic) message from
visitable
. This is especially important when your test needs to know what kind of error was triggered. For example some tests might want to handleTransitionAborted
errors differently, see emberjs/ember-test-helpers#332 (comment).