Fix some documentation to use expectLater (#1163)
Closes #1015
Our recommendation is that code which wants to `await` the result of an
expectation should use `expectLater`. Update the docs and README to
reflect this.
diff --git a/pkgs/test/README.md b/pkgs/test/README.md
index 6e17409..1dced93 100644
--- a/pkgs/test/README.md
+++ b/pkgs/test/README.md
@@ -459,14 +459,14 @@
]));
// Ignore lines from the process until it's about to emit the URL.
- await expect(stdout, emitsThrough('WebSocket URL:'));
+ await expectLater(stdout, emitsThrough('WebSocket URL:'));
// Parse the next line as a URL.
var url = Uri.parse(await stdout.next);
expect(url.host, equals('localhost'));
// You can match against the same StreamQueue multiple times.
- await expect(stdout, emits('Waiting for connection...'));
+ await expectLater(stdout, emits('Waiting for connection...'));
});
}
```
diff --git a/pkgs/test_api/lib/src/frontend/stream_matcher.dart b/pkgs/test_api/lib/src/frontend/stream_matcher.dart
index 5446e2c..6eade9e 100644
--- a/pkgs/test_api/lib/src/frontend/stream_matcher.dart
+++ b/pkgs/test_api/lib/src/frontend/stream_matcher.dart
@@ -48,14 +48,14 @@
/// var stdout = StreamQueue(stdoutLineStream);
///
/// // Ignore lines from the process until it's about to emit the URL.
-/// await expect(stdout, emitsThrough("WebSocket URL:"));
+/// await expectLater(stdout, emitsThrough('WebSocket URL:'));
///
/// // Parse the next line as a URL.
/// var url = Uri.parse(await stdout.next);
/// expect(url.host, equals('localhost'));
///
/// // You can match against the same StreamQueue multiple times.
-/// await expect(stdout, emits("Waiting for connection..."));
+/// await expectLater(stdout, emits('Waiting for connection...'));
/// ```
///
/// Users can call [new StreamMatcher] to create custom matchers.