Add test for profile mode diagnostics (#17492)

* Add test for profile mode diagnostics

* revert cirrus change
diff --git a/e2etests/web/regular_integration_tests/lib/profile_diagnostics_main.dart b/e2etests/web/regular_integration_tests/lib/profile_diagnostics_main.dart
new file mode 100644
index 0000000..26dba54
--- /dev/null
+++ b/e2etests/web/regular_integration_tests/lib/profile_diagnostics_main.dart
@@ -0,0 +1,25 @@
+// Copyright 2013 The Flutter 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:flutter/material.dart';
+import 'package:flutter/services.dart';
+
+void main() {
+  runApp(MyApp());
+}
+
+class MyApp extends StatefulWidget {
+  @override
+  MyAppState createState() => MyAppState();
+}
+
+class MyAppState extends State<MyApp> {
+  String kMessage = 'ABC';
+  @override
+  Widget build(BuildContext context) {
+    // cause cast error.
+    print(kMessage as int);
+    return Text('Hello');
+  }
+}
diff --git a/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e.dart b/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e.dart
new file mode 100644
index 0000000..485a777
--- /dev/null
+++ b/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e.dart
@@ -0,0 +1,22 @@
+// Copyright 2013 The Flutter 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 'dart:html' as html;
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:regular_integration_tests/profile_diagnostics_main.dart' as app;
+
+import 'package:e2e/e2e.dart';
+
+void main() {
+  E2EWidgetsFlutterBinding.ensureInitialized() as E2EWidgetsFlutterBinding;
+
+  testWidgets('App build method exception should form valid FlutterErrorDetails',
+          (WidgetTester tester) async {
+    app.main();
+    await tester.pumpAndSettle();
+    final dynamic appError = tester.takeException();
+    expect(appError, isA<TypeError>());
+  });
+}
diff --git a/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e_test.dart b/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e_test.dart
new file mode 100644
index 0000000..a29203f
--- /dev/null
+++ b/e2etests/web/regular_integration_tests/test_driver/profile_diagnostics_e2e_test.dart
@@ -0,0 +1,7 @@
+// Copyright 2013 The Flutter 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:e2e/e2e_driver.dart' as e2e;
+
+Future<void> main() async => e2e.main();