Skip to content

Testing and debugging

Pure business functions can be tested in ordinary Python. UI rendering needs the browser bridge or Node/Pyodide renderer; importing a UI function in CPython and calling it is not a DOM test.

Native and server tests

From a framework source checkout:

python -m pip install -e .
python -m unittest discover -s tests -v

SSR cases are skipped unless PYREACT_FORGE_PYODIDE is set to a local runtime. An unqualified green native test run does not mean the browser suite ran.

Full browser suite

npm ci
npm run build:runtime
npx playwright install chromium

Set the runtime path, then run the suite:

$env:PYREACT_FORGE_PYODIDE = (Resolve-Path node_modules/pyodide).Path
python -m unittest discover -s tests -v
npm run test:browser
export PYREACT_FORGE_PYODIDE="$PWD/node_modules/pyodide"
python -m unittest discover -s tests -v
npm run test:browser

CHROMIUM_PATH selects an existing binary. The suite launches local servers, interacts with real DOM elements and exercises the examples. It is targeted integration coverage, not the upstream React conformance suite.

Documentation tests

python -m pip install -r requirements-docs.txt
python scripts/generate_api.py --check
python -m zensical build --strict
python scripts/check_docs.py

The checker validates built internal links/assets, anchors, the sitemap/search index and Python snippet syntax. It does not prove every tutorial's runtime behavior or validate external sites that may be unpublished.

Report a useful bug

Provide package version, browser/OS, CSR or SSR mode, the complete error and a minimal app.py plus forge.json. Remove private data. Use browser DevTools for client tracebacks, and read the terminal for build/server errors. debug_stats() can help investigate retained Python callbacks/values; garbage collection is nondeterministic, so it is a diagnostic rather than a memory-safety guarantee.