Configure integration tests to run on `dart2wasm` (#9743)
diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index e62b58f..a36d902 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -208,7 +208,7 @@
         # TODO(https://github.com/flutter/devtools/issues/9357): Re-enable tests on windows-latest.
         os: [macos-latest]
         # Consider running integration tests in ddc mode, too.
-        bot: [integration_dart2js]
+        bot: [integration_dart2js, integration_dart2wasm]
         device: [flutter, flutter-web, dart-cli]
         # Option 1/1 will run all tests for a device in a single shard.
         # Option 1/2 and 2/2 should be enabled to run tests for a device in 2 shards.
@@ -273,7 +273,7 @@
       fail-fast: false
       matrix:
         # Consider running integration tests in ddc mode, too.
-        bot: [integration_dart2js]
+        bot: [integration_dart2js, integration_wasm]
         os: [ubuntu-latest, windows-latest]
     steps:
       - name: git clone
diff --git a/packages/devtools_app/integration_test/test_infra/run/run_test.dart b/packages/devtools_app/integration_test/test_infra/run/run_test.dart
index 3daeee0..e815316 100644
--- a/packages/devtools_app/integration_test/test_infra/run/run_test.dart
+++ b/packages/devtools_app/integration_test/test_infra/run/run_test.dart
@@ -82,6 +82,7 @@
       testTarget,
       testDriver: 'test_driver/integration_test.dart',
       headless: testRunnerArgs.headless,
+      useWasm: testRunnerArgs.useWasm,
       dartDefineArgs: [
         'test_args=${jsonEncode(testArgs)}',
         if (testFileArgs.experimentsOn) 'enable_experiments=true',
diff --git a/packages/devtools_extensions/integration_test/run_tests.dart b/packages/devtools_extensions/integration_test/run_tests.dart
index 1eb213d..64d38b3 100644
--- a/packages/devtools_extensions/integration_test/run_tests.dart
+++ b/packages/devtools_extensions/integration_test/run_tests.dart
@@ -38,6 +38,7 @@
       testRunnerArgs.testTarget!,
       testDriver: 'test_driver/integration_test.dart',
       headless: testRunnerArgs.headless,
+      useWasm: testRunnerArgs.useWasm,
       dartDefineArgs: ['use_simulated_environment=true'],
       debugLogging: debugTestScript,
     );
diff --git a/packages/devtools_shared/lib/src/test/integration_test_runner.dart b/packages/devtools_shared/lib/src/test/integration_test_runner.dart
index de88474..54e0f8b 100644
--- a/packages/devtools_shared/lib/src/test/integration_test_runner.dart
+++ b/packages/devtools_shared/lib/src/test/integration_test_runner.dart
@@ -27,6 +27,7 @@
     String testTarget, {
     required String testDriver,
     bool headless = false,
+    bool useWasm = false,
     List<String> dartDefineArgs = const <String>[],
     bool debugLogging = false,
   }) async {
@@ -51,7 +52,10 @@
         headless ? 'web-server' : 'chrome',
         // --disable-gpu speeds up tests that use ChromeDriver when run on
         // GitHub Actions. See https://github.com/flutter/devtools/issues/8301.
-        '--web-browser-flag=--disable-gpu',
+        // However, it also breaks the tests when running with the wasm flag,
+        // because it prevents capturing browser logs. See:
+        // https://github.com/flutter/devtools/issues/9727
+        useWasm ? '--wasm' : '--web-browser-flag=--disable-gpu',
         if (headless) ...[
           // Flags to avoid breakage with chromedriver 138. See
           // https://github.com/flutter/devtools/issues/9357.
@@ -223,6 +227,9 @@
   /// instead of 'chrome'.
   bool get headless => argResults.flag(_headlessArg);
 
+  /// Whether this integration test should be run against dart2wasm-compiled DevTools.
+  bool get useWasm => argResults.flag(_wasmArg);
+
   /// Sharding information for this test run.
   ({int shardNumber, int totalShards})? get shard {
     final shardValue = argResults.option(_shardArg);
@@ -250,6 +257,7 @@
   static const _helpArg = 'help';
   static const testTargetArg = 'target';
   static const _headlessArg = 'headless';
+  static const _wasmArg = 'wasm';
   static const _shardArg = 'shard';
 
   /// Builds an arg parser for DevTools integration tests.
@@ -277,6 +285,11 @@
             'the \'chrome\' device. For headless test runs, you will not be '
             'able to see the integration test run visually in a Chrome browser.',
       )
+      ..addFlag(
+        _wasmArg,
+        negatable: false,
+        help: 'Runs the integration test against dart2wasm-compiled DevTools.',
+      )
       ..addOption(
         _shardArg,
         valueHelp: '1/3',
diff --git a/tool/ci/bots.sh b/tool/ci/bots.sh
index 60ed776..bd4a4b6 100755
--- a/tool/ci/bots.sh
+++ b/tool/ci/bots.sh
@@ -72,7 +72,13 @@
 # elif [ "$BOT" = "integration_ddc" ]; then
 
 # TODO(https://github.com/flutter/devtools/issues/1987): rewrite legacy integration tests.
-elif [ "$BOT" = "integration_dart2js" ]; then
+elif [[ "$BOT" == "integration_dart2js" || "$BOT" == "integration_dart2wasm" ]]; then
+    if [ "$BOT" == "integration_dart2wasm" ]; then
+        WASM_FLAG="--wasm"
+    else
+        WASM_FLAG=""
+    fi
+
     if [ "$DEVTOOLS_PACKAGE" = "devtools_app" ]; then
         flutter pub get
 
@@ -85,15 +91,15 @@
 completed). Download these goldens and update them in the codebase to apply the updates."
 
         if [ "$DEVICE" = "flutter" ]; then
-            dart run integration_test/run_tests.dart --headless --shard="$SHARD"
+            dart run integration_test/run_tests.dart $WASM_FLAG --headless --shard="$SHARD"
         elif [ "$DEVICE" = "flutter-web" ]; then
-            dart run integration_test/run_tests.dart --test-app-device=chrome --headless --shard="$SHARD"
+            dart run integration_test/run_tests.dart --test-app-device=chrome $WASM_FLAG --headless --shard="$SHARD"
         elif [ "$DEVICE" = "dart-cli" ]; then
-            dart run integration_test/run_tests.dart --test-app-device=cli --headless --shard="$SHARD"
+            dart run integration_test/run_tests.dart --test-app-device=cli $WASM_FLAG --headless --shard="$SHARD"
         fi
     elif [ "$DEVTOOLS_PACKAGE" = "devtools_extensions" ]; then
         pushd $DEVTOOLS_DIR/packages/devtools_extensions
-        dart run integration_test/run_tests.dart --headless
+        dart run integration_test/run_tests.dart $WASM_FLAG --headless
         popd
     fi
 fi