-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
The perform helper crashes QUnit tests when the task fails or is cancelled #435
Comments
Yeah, I think this is the case in ember-mocha as well. There's some general questions in ember-concurrency around error handling about whether we should throw errors when the error states are used, but this behavior is I guess by-design too. Would recommend using the |
I had tried it like this: debugger;
setupOnerror((error) => {
debugger;
}); I can see only the first |
I guess this may depend on how/where you're using it You could also try something like the |
Well, I have described exactly how I'm using it.
Well, the point of this issue is to discus the possiblity of including this functionality into the Is there even a case where you do want tests to fail when a |
The snippet provided lacks context and doesn't make a runnable example I can faithfully reproduce, so it's difficult for me to infer from it why
ah, I missed that ask at the bottom. This is definitely something we could do in the
if someone isn't using |
I've tried replicating it on Twiddle, and Not sure why that's not the case for me. Maybe because we're two Ember versions ahead, IDK...
It could be op-in: <button
{{on "click" (perform this.submitTask "arg1" "arg2" catch=true)}}
>
That would be black magic. Someone will be doomed to have a hair-pulling frustration over it. :) |
yeah, I think opt-in is probably the way to go. will probably do something like |
@maxfierke Thanks! 🙏 |
The problem is that QUnit chooses to crash tests unconditionally on an unhandled rejected promise.
Say, I've got this basic setup:
This is perfectly valid code: it adheres to Ember Concurrency guidelines and it works flawlessly in production.
The problem happens when I try to test the failed state:
This is also a perfectly valid test, yet QUnit chooses to crash it because the promise generated by the
perform
helper has been rejected and not handled.The workaround is to replace this:
With this:
This is a huge bummer, because this runtime boilerplate is absolutely unnecessary for production and only exists to please QUnit.
I believe this is an issue with QUnit and has nothing to do with Ember Concurrency. Yet, @rwjblue has confirmed that this QUnit behavior is intended and that QUnit was deliberately modified to behave like that.
Given that this QUnit behavior is official, it basically renders the
perform
helper faulty as it would crash the tests for failed and cancelled EC tasks.I would like to start a discussion regarding what can be done to mitigate this. E. g. can the
perform
helper internally catch the promise returned by the task?CC @simonihmig
The text was updated successfully, but these errors were encountered: