-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Async pending
fails the spec when used with Promises
#1450
Comments
Similar to #1449 |
I spend a few hours yesterday reading the code around this issue and looking into possible way fix this issue. Essentially the issue can be caught within QueueRunner's atttach() at:
maybeThenable is called and if promise fails, it goes to next.fail() - Now, if someone could point out how i could get a reference to running Spec from that point on so that i could mark it pending would be nice. As, just comparing the error in next.fail() to pending i'm already able to prevent the actual error but reporting the spec as pending wont happen.. |
@rasjani this should be fixed on master now. If you have a chance, please take a look and if you're still seeing the issue with the updated code let us know. Thanks for using Jasmine! |
@slackersoft Is this supposed to fix angular/jasminewd#32 as well? |
@fushi That's likely to have been already working for a release or four, depending on exactly what flavor of async spec we're talking about. |
@sgravrock I'm using Protractor/Jasmine, and still hitting this issue with:
Which fails like this:
|
This functionality should have been released in Jasmine 2.9. You'll have to make sure your Protractor is using the newest version of Jasmine to get this fix. |
@slackersoft Is there a way to programmatically find if the |
Since Hope this helps. Thanks for using Jasmine! |
@slackersoft Yes, I am passing a custom handler. How can I get an error message? Is there a specific function in jasmine to do that? Can I programmatically set a spec to pending if I see Pending string in the thrown error string? If yes, how? Any help with that? |
@jasmine4ever this seems to have move quite far away from the original intent in this issue. Please start a new conversation with some more specifics on your actual use case. This probably belongs on the jasmine-js group, since this sounds more like a "how do I?" question, than an issue with Jasmine itself. Thanks for using Jasmine! |
Didn't knew about the group. Will start a thread there. Thank you. |
I have the latest version of Jasmine v3.3.0 and get error when calling |
@ViieeS, please open a new issue and provide us with some more information about what you're seeing. |
To skip test block programmatically, please use example:
|
This spec isn't correct:
It does two different things that Jasmine doesn't support: It both takes a callback and returns a promise, and it runs more code after it signals completion. Depending on the exact version of Jasmine in use it might appear to work correctly, it might pend the wrong spec, it might trigger a failure, or it might misbehave in other ways. In any case, there shouldn't be a need for workarounds like that. This bug has been fixed for 3.5 years now. If anyone is still unable to make a promise-returning spec pend by simply calling |
The work done to handle global errors in async specs using the
done
callback correctly collects the pending exception and marks the spec appropriately. When callingpending
from within a Promise returned by a spec, it is treated as a Promise failure and doesn't mark the spec as pending.Example suite:
Output:
Possible Solution
It looks like the
Spec
object only checks for theisPendingSpecException
when handling an exception, but theQueueRunner
passes Promise failures along viafail
which causes them to skip this logic and go directly to the expectation failure handler.The goal of using
fail
in QueueRunner was to not have to duplicate the continuation logic, but it probably needs to change to handle a Promise rejection as anError
and then continue on after that.Your Environment
We would be happy to review a pull request that addresses this issue.
The text was updated successfully, but these errors were encountered: