Simple function that waits for a condition to be true and runs the supplied callback. Great for testing promises where the promise is not accessible in the test.