Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkgs/test/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
compiled artifact until the end of the run.
* Fail to load a test suite compiled with the `exe` or `cli` compiler if the
test process exits before connecting to the runner, instead of hanging.
* Wait longer for Chrome to open the test page when running with `--debug` or
`--coverage`, and list the open tabs if the page is never found.

## 1.32.0

Expand Down
11 changes: 8 additions & 3 deletions pkgs/test/lib/src/runner/browser/chrome.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,22 @@ Future<(WipConnection, Uri)> _connect(
.firstWhere((line) => line.startsWith('DevTools listening'));

var chromeConnection = ChromeConnection('localhost', port);
// The browser opens a redirect page first, so the tab can take a while to
// reach [url] on a heavily loaded machine. Wait up to about 20 seconds.
ChromeTab? tab;
var attempt = 0;
while (tab == null) {
attempt++;
var tabs = await chromeConnection.getTabs();
tab = tabs.firstWhereOrNull((tab) => tab.url == url.toString());
if (tab == null) {
await Future<void>.delayed(const Duration(milliseconds: 200));
if (attempt > 20) {
throw StateError('Could not connect to test tab with url: $url');
if (attempt >= 100) {
throw StateError(
'Could not connect to test tab with url: $url\n'
'Open tabs: ${tabs.map((tab) => tab.url).join(', ')}',
);
}
await Future<void>.delayed(const Duration(milliseconds: 200));
}
}
var tabConnection = await tab.connect();
Expand Down
Loading