test_testing.py 991 B

123456789101112131415161718192021222324252627282930313233343536
  1. """Unit tests for the included testing tools."""
  2. from reflex.constants import IS_WINDOWS
  3. from reflex.testing import AppHarness
  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. class State(rx.State):
  15. pass
  16. app = rx.App(state=State)
  17. app.add_page(lambda: rx.text("Basic App"), route="/", title="index")
  18. app.compile()
  19. with AppHarness.create(
  20. root=tmp_path,
  21. app_source=BasicApp, # type: ignore
  22. ) as harness:
  23. assert harness.app_instance is not None
  24. assert harness.backend is not None
  25. assert harness.frontend_url is not None
  26. assert harness.frontend_process is not None
  27. assert harness.frontend_process.poll() is None
  28. assert harness.frontend_process.poll() is not None