Skip to content
Discussion options

You must be logged in to vote

Testing Reflex apps with pytest

Two layers cover most needs:

1. Static component tests — call your page/section functions and walk
the returned rx.Component tree. No browser, sub-second. Catches typos
and missing sections.

2. End-to-end with reflex.testing.AppHarness + Playwright — boots
the real app and drives a headless browser.

# conftest.py — session-scoped so the dev server boots once
from pathlib import Path
import pytest
from reflex.testing import AppHarness

@pytest.fixture(scope="session")
def my_app():
    app_root = Path(__file__).parent.parent  # dir containing rxconfig.py
    with AppHarness.create(root=app_root) as harness:
        yield harness
# test_e2e.py
from playwright.s…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by srgee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants