Nimble
Nimble copied to clipboard
Unable to verify that an async function eventually sends an NSNotification.
The following test does not work:
func asyncFunctionPostingNotification() async {
// ...
NotificationCenter.default.post(...)
}
expect { await asyncFunctionPostingNotification() }.to(postNotification(...))
Because of how async expectations are implemented, the Expression (await asyncFunctionPostingNotification() }
is called before the matcher (postNotification(...)
) is called. This is a result of the approach we take with async expressions, where the expression is evaluated, then the result of the expression is passed into the matcher.
Perhaps we should take this as a chance to rethink how AsyncExpectation
works, and provide full end-to-end support for async expressions. We could use something approaching the current method as a fallback for existing, non-async matchers.