smoke test VM service connection before returning VMService object (#12914)
diff --git a/packages/flutter_tools/test/vmservice_test.dart b/packages/flutter_tools/test/vmservice_test.dart
new file mode 100644
index 0000000..6cb0714
--- /dev/null
+++ b/packages/flutter_tools/test/vmservice_test.dart
@@ -0,0 +1,21 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+import 'package:web_socket_channel/web_socket_channel.dart';
+import 'package:test/test.dart';
+
+import 'package:flutter_tools/src/base/port_scanner.dart';
+import 'package:flutter_tools/src/vmservice.dart';
+
+void main() {
+ group('VMService', () {
+ test('fails connection eagerly in the connect() method', () async {
+ final int port = await const HostPortScanner().findAvailablePort();
+ expect(
+ VMService.connect(Uri.parse('http://localhost:$port')),
+ throwsA(const isInstanceOf<WebSocketChannelException>()),
+ );
+ });
+ });
+}