reflex-testing-state
Skill4 starsChanged 5 months agoMITView on GitHub
Generates pytest unit tests for Reflex.dev state logic — event handlers, computed vars, substates, and mocked external dependencies. Use when the user asks to write, scaffold, or review tests for a Reflex State class. Do NOT use for Playwright
- Installs packages
In this repository28 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- appkit-commonsSkill
- boostSkill
- code-cleanupSkill
- commit-msgSkill
- create-readmeSkill
- docker-multi-stageSkill
- frontend-designSkill
- github-actions-cicdSkill
- python-clean-codeSkill
- python-codingSkill
- reflex-docsSkill
- reflex-state-and-architectureSkill
- releaseSkill
- runic-migrateSkill
- runic-ogmSkill
- terraform-azure-verified-modulesSkill
- terraform-refactor-moduleSkill
- terraform-run-acceptance-testsSkill
- terraform-search-importSkill
- terraform-stacksSkill
- terraform-style-guideSkill
- terraform-testSkill
- appkit-commonsSkill
- appkit-mantine-referenceSkill
- appkit-userSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 13
Test it directly with pytest and pytest-asyncio.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Testing Reflex State
Reflex State is a plain Python class — no browser or runtime needed.
Test it directly with pytest and pytest-asyncio.
Setup
pip install pytest pytest-asyncio pytest-covpyproject.toml:
[tool.pytest.ini_options]
testpaths = ["tests/unit"]
asyncio_mode = "auto"
python_files = ["test_*.py"]File layout
tests/unit/
├── conftest.py
├── test_base_state.py
└── test_project_state.pyPatterns
Base vars → test defaults directly
Sync handlers → call on instance, assert result
Async handlers → await, assert is_loading is False after
Streaming handlers → consume with async for
Computed vars → mutate base vars, assert property
Substates → instantiate subclass independently
External I/O → unittest.mock.patch at myapp.state.*
Background tasks → patch __aenter__/__aexit__
See references/PATTERNS.md for full code examples. See references/FIXTURES.md for shared fixture setup.
Decision: which pattern to use?
Sync handler? → Test directly, no async
Async handler? → Use await, check loading flag resets
Handler bound to Radix UI component? → Add str AND list[str] test cases
Handler calls API/DB? → Mock with AsyncMock, test both success and failure
Background task (@rx.event(background=True))? → Patch context manager
Run
pytest tests/unit/ -v --cov=myapp/state --cov-report=term-missing
pytest tests/unit/test_project_state.py -v # single module
pytest tests/unit/ -x # stop on first failureDoes it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

