-
-
Notifications
You must be signed in to change notification settings - Fork 600
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
How do I expect notifications correctly in an async context? #1012
Comments
Did I maybe misunderstand and this #1007 is not in 11.1 but will be in a later version? |
My apologies for the poor wording. I struggled with how to correctly word that message. Prepend |
Hi and thank you for the quick answer, It seems to be required to run on the main thread? It's tripping an assertion on This is my first project with async/await so I'm a bit shaky. I tried surrounding that with
But that triggers a compile error Part of me wants to tag everything with await up the chain, but that doesn't make sense as I earlier had |
Oh. I'm sorry. I misunderstood what you were doing. This is confusing, and I'm sorry. As of Nimble 11, toEventually does not work async Expressions. That is,
I would like to fix this, but I've yet to come up with a good solution for all of the problems introduced by it. Again, I'm really sorry for this confusion. |
No worries I appreciated the detailed and patient explanation. So there's currently no way to test an async function for notifications then - is that right? Maybe I can look into XCTest for that part and have Nimble do everything else. I appreciate all the work done in Nimble - this is my second project with it and it just makes sense. :) |
That's correct. You could certainly cobble together something yourself that does it, but Nimble doesn't provide anything out of the box for this. I created #1013 to specifically track this issue (and in general other wonkiness with the approach I took when implementing Async support for expectations). |
Got it, thanks for your help. |
What did you do?
Added code trying to test for a notification being fired in an async context:
let notification = Notification(name: Constants.BadJSONNotification)
expect {
await expect(await provisioningManager.processJSON(badJSON).to(beFalse())
}.toEventually(postNotifications(equal([notification])))
What did you expect to happen?
Initially expected it to work. I got the warning:
Instance method 'toEventually' is unavailable from asynchronous contexts; the sync version of
toEventuallydoes not work in async contexts. Use the async version with the same name as a drop-in replacement; this is an error in Swift 6
and have so far completely failed to find the async version
What actually happened instead?
I have completely failed to either find an example, documentation, or the definition of the aforementioned async version.
Environment
List the software versions you're using:
Xcode Default
.)Please also mention which package manager you used and its version. Delete the
other package managers in this list:
Project that demonstrates the issue
Nothing to demonstrate just hopefully someone can point me to the right place if this is supported.
The text was updated successfully, but these errors were encountered: