test_testing.py 941 B

123456789101112131415161718192021222324252627282930313233
  1. """Unit tests for the included testing tools."""
  2. from reflex.testing import AppHarness
  3. from reflex.utils.prerequisites import IS_WINDOWS
  4. def test_app_harness(tmp_path):
  5. """Ensure that AppHarness can compile and start an app.
  6. Args:
  7. tmp_path: pytest tmp_path fixture
  8. """
  9. # Skip in Windows CI.
  10. if IS_WINDOWS:
  11. return
  12. def BasicApp():
  13. import reflex as rx
  14. app = rx.App()
  15. app.add_page(lambda: rx.text("Basic App"), route="/", title="index")
  16. app.compile()
  17. with AppHarness.create(
  18. root=tmp_path,
  19. app_source=BasicApp, # type: ignore
  20. ) as harness:
  21. assert harness.app_instance is not None
  22. assert harness.backend is not None
  23. assert harness.frontend_url is not None
  24. assert harness.frontend_process is not None
  25. assert harness.frontend_process.poll() is None
  26. assert harness.frontend_process.poll() is not None