Assert condition with timeout

In my test suite I occasionally find myself needing to work with timeouts if some processing is done asynchronously. In this case I often resort to

:timer.sleep(100)
assert condition

Is there a way to instead specify an assertion that takes a condition and a timeout with the following logic: If the condition holds before the timeout is up then the test passes. Otherwise it fails. If that assertion would not simply implement the above but check regularly, say every ms, then this would allow for

  • a more robust test suite as the timeout can be put to a much larger value than the above sleep workaround
  • for a much faster test suite, since the full sleep is usally superfluous.

Implementing this functionality with a macro should be (I guess) straight forward. If so, are there by any chance already any libraries that offer this type of assertion or if not, is the above an anti-pattern that should be avoided?