code: def run_e2e_tests(
      always_continue: bool,
      record_results: bool,
      update_snapshots: bool,
      flaky_tests: bool,
      tests: List[str],
      verbose: bool,
  ):
      """Run e2e tests. If any fail, exit with non-zero status."""
      kill_streamlits()
      kill_app_servers()
      app_server = run_app_server()
  
      # Clear reports from previous runs
      remove_if_exists("frontend/test_results/cypress")
  
      ctx = Context()
      ctx.always_continue = always_continue
      ctx.record_results = record_results
      ctx.update_snapshots = update_snapshots
      ctx.tests_dir_name = "e2e_flaky" if flaky_tests else "e2e"
  
      try:
          p = Path(
              join(ROOT_DIR, ctx.tests_dir_name, "specs")
          ).resolve()
          if tests:
              paths = [Path(t).resolve() for t in tests]
          else:
              paths = sorted(p.glob("*.spec.js"))
          for spec_path in paths:
              if basename(spec_path) == "st_hello.spec.js":
                  if flaky_tests:
                      continue
  
                  # Test "streamlit hello" in both headless and non-headless mode.
                  run_test(
                      ctx,
                      str(spec_path),
                      ["streamlit", "hello", "--server.headless=false"],
                      show_output=verbose,
                  )
                  run_test(
                      ctx,
                      str(spec_path),
                      ["streamlit", "hello", "--server.headless=true"],
                      show_output=verbose,
                  )
  
              elif basename(spec_path) == "staticfiles_app.spec.js":
                  test_name, _ = splitext(basename(spec_path))
                  test_name, _ = splitext(test_name)
                  test_path = join(
                      ctx.tests_dir,
                      "scripts",
                      "staticfiles_apps",
                      "streamlit_static_app.py",
                  )
                  if os.path.exists(test_path):
                      run_test(
                          ctx,
                          str(spec_path),
                          [
                              "streamlit",
                              "run",
                              "--server.enableStaticServing=true",
                              test_path,
                          ],
                          show_output=verbose,
                      )
              elif basename(spec_path) == "hostframe.spec.js":
                  test_name, _ = splitext(basename(spec_path))
                  test_name, _ = splitext(test_name)
                  test_path = join(
                      ctx.tests_dir,
                      "scripts",
                      "hostframe",
                      "hostframe_app.py",
                  )
                  if os.path.exists(test_path):
                      run_test(
                          ctx,
                          str(spec_path),
                          [
                              "streamlit",
                              "run",
                              test_path,
                          ],
                          show_output=verbose,
                      )
  
              else:
                  test_name, _ = splitext(basename(spec_path))
                  test_name, _ = splitext(test_name)
                  test_path = join(
                      ctx.tests_dir, "scripts", f"{test_name}.py"
                  )
                  if os.path.exists(test_path):
                      run_test(
                          ctx,
                          str(spec_path),
                          ["streamlit", "run", test_path],
                          show_output=verbose,
                      )
      except QuitException:
          # Swallow the exception we raise if the user chooses to exit early.
          pass
      finally:
          if app_server:
              app_server.terminate()
  
      if ctx.any_failed:
          sys.exit(1)
  
imports: import os
  import shutil
  import signal
  import subprocess
  import sys
  import time
  from contextlib import contextmanager
  from os.path import abspath, basename, dirname, join, splitext
  from pathlib import Path
  from tempfile import TemporaryFile
  from typing import List
  import click
  import requests
label_desc: Use image node_id 10 for calling a global function with example usage: run_e2e_tests(always_continue, record_results, update_snapshots, flaky_tests, tests, verbose) without return types