def e2e_environment(test_environment) -> Generator[E2ETestRunner, None, None]:
    """Set up and tear down the E2E test environment.

    This fixture starts all required services using docker-compose
    and tears them down after all tests are complete.

    Only sets up the environment if we're in test mode.
    """
    global _runner

    # Skip setup in onboarding mode - services are already running
    if test_environment["env"] != "test":
        yield None
        return

    # Create runner with minimal mode (postgres and backend only)
    # This avoids issues with Weaviate and Neo4j that can be flaky in tests
    if _runner is None:
        _runner = E2ETestRunner()

    try:
        # Start services (or reuse existing ones)
        logger.info("Starting or reusing E2E test environment")
        _runner.setup()

        # Yield runner for additional operations if needed
        yield _runner
    except Exception as e:
        logger.error(f"Error during E2E environment setup: {e}")
        raise
Set up and tear down the E2E test environment.

    This fixture starts all required services using docker-compose
    and tears them down after all tests are complete.

    Only sets up the environment if we're in test mode.
    
backend/tests/e2e/conftest.py