Repository navigation
Add expectLater to flutter_test - #17063
Conversation
* Wrap `expectLater()` in flutter_tester so that callers can wait for the matcher to complete in their tests #16859
| @@ -158,6 +158,19 @@ void expectSync(dynamic actual, dynamic matcher, { | |||
| test_package.expect(actual, matcher, reason: reason); | |||
| } | |||
|
|
|||
There was a problem hiding this comment.
Mention expectLater in expect's documentation.
Have expect assert that it didn't get a Future back, and if it did, fail with a message saying that you either have a bug or you should consider expectLater.
There was a problem hiding this comment.
expect can't get a future back, because it calls test_package.expect(), which returns void.
There was a problem hiding this comment.
Ugh, that's quite unfortunate.
| /// has finished matching. | ||
| /// | ||
| /// If the matcher fails asynchronously, that failure is piped to the returned | ||
| /// future where it can be handled by user code. |
There was a problem hiding this comment.
Explain what happens if it isn't handled by user code (presumably the test fails?)
| String reason, | ||
| dynamic skip, // true or a String | ||
| }) { | ||
| TestAsyncUtils.guardSync(); |
There was a problem hiding this comment.
Should this be wrapped in a guard, rather than just being a synchronous guard? Or is it ok if expectLater isn't awaited?
There was a problem hiding this comment.
Turns out this does need to just be guardSync(). Otherwise, we run into other async barriers while we're waiting for the matcher to complete. e.g.:
|
tests? |
I can't test this without #17029, or the test will timeout 😛 |
Actually, I can use |
|
Tests added |
|
Merging on red because of a suspected flake. |
* Wrap `expectLater()` in flutter_tester so that callers can wait for the matcher to complete in their tests flutter#16859
expectLater()in flutter_tester so that callers canwait for the matcher to complete in their tests
#16859