test_testing.py 831 B

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