Skip to content

How do I expect notifications correctly in an async context? #1012

@abushnaq-work

Description

@abushnaq-work
  • I have read CONTRIBUTING and have done my best to follow them.

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 toEventually does 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:

  • Quick: 6.0.0
  • Nimble: 11.1.0
  • Xcode Version: 14.0(14A309) (Open Xcode; In menubar: Xcode > About Xcode)
  • Swift Version: Xcode default (Open Xcode Preferences; Components > Toolchains. If none, use Xcode Default.)

Please also mention which package manager you used and its version. Delete the
other package managers in this list:

  • Swift Package Manager 5.6.0

Project that demonstrates the issue

Nothing to demonstrate just hopefully someone can point me to the right place if this is supported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions