diff --git a/reflex/config.py b/reflex/config.py index 7a7179588..c3c1c23b7 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -491,6 +491,9 @@ class EnvironmentVariables: # If this env var is set to "yes", App.compile will be a no-op REFLEX_SKIP_COMPILE: EnvVar[bool] = env_var(False, internal=True) + # Whether to run app harness tests in headless mode. + APP_HARNESS_HEADLESS: EnvVar[bool] = env_var(False) + environment = EnvironmentVariables() diff --git a/reflex/testing.py b/reflex/testing.py index b786390ae..5a4f4e1db 100644 --- a/reflex/testing.py +++ b/reflex/testing.py @@ -617,7 +617,7 @@ class AppHarness: if self.frontend_url is None: raise RuntimeError("Frontend is not running.") want_headless = False - if os.environ.get("APP_HARNESS_HEADLESS"): + if environment.APP_HARNESS_HEADLESS.get: want_headless = True if driver_clz is None: requested_driver = os.environ.get("APP_HARNESS_DRIVER", "Chrome") diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 212ac9981..98c5fda39 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -6,6 +6,7 @@ from pathlib import Path import pytest +from reflex.config import environment from reflex.testing import AppHarness, AppHarnessProd DISPLAY = None @@ -21,7 +22,7 @@ def xvfb(): Yields: the pyvirtualdisplay object that the browser will be open on """ - if os.environ.get("GITHUB_ACTIONS") and not os.environ.get("APP_HARNESS_HEADLESS"): + if os.environ.get("GITHUB_ACTIONS") and not environment.APP_HARNESS_HEADLESS.get: from pyvirtualdisplay.smartdisplay import ( # pyright: ignore [reportMissingImports] SmartDisplay, )