Testing ​

Tests are split by the browser boundary they cross.

Contract tests ​

bash
npm run test:contract

Node’s built-in test runner covers protocol validation, URL scopes, Service Worker routing and caching, backend envelopes, instance catalogs, client composables (useFrameNavigation, useAppManager, useInstanceManager, usePlaygroundLifecycle), runtime version consistency, app-catalog recipes, and server modules. The command regenerates Python sources first.

Run this suite for nearly every code change; it is fast and does not boot Pyodide in a browser.

Python unit tests ​

bash
python3 -m unittest discover -s tests/unit

Python’s built-in unittest runner tests runtime Python components directly without needing a browser or Pyodide:

  • test_mariadb_polyfills.py: MariaDB string functions (CONCAT, CONCAT_WS, FIELD, LOCATE), sequence generation (tabSeries, get_next_sequence_val), and case-insensitive lookups on SQLite;
  • test_wsgi_server.py: WSGI request adaptation, header parsing, cookie jars, and uploaded file serving; and
  • test_site_ops.py: site operations and database patching.

Clean-build verification ​

bash
npm run test:clean-build
npm run verify:build

These commands catch stale output, missing publish files, broken worker imports, catalog/archive hash mismatches, and generated files placed in the wrong directory.

End-to-end tests ​

bash
npm run test:e2e:chromium
npm run test:e2e:webkit

Playwright owns a production preview at http://127.0.0.1:8102 unless PLAYWRIGHT_BASE_URL points to an externally managed deployment. The per-test timeout is ten minutes because a cold Pyodide/Frappe boot is substantial. Traces and screenshots are retained under tests/results/.

Focused specs cover:

AreaSpec
Basic boot and progressboot.spec.js, full_flow.spec.js
Login and Setup Wizardlogin.spec.js, setup_wizard.spec.js, boot_flags.spec.js
Desk and app lifecycledesk.spec.js, app_install.spec.js
Persistence and filescache_persistence.spec.js, file_upload.spec.js
Multiple instancesmulti_instance.spec.js
Routing and recoveryscoped_reload.spec.js, scope_escape.spec.js, shell_recovery.spec.js, sw_behavior.spec.js
Static output and mobile UIstatic_files.spec.js, mobile_shell.spec.js

Complete suite ​

bash
npm test

This runs contract tests, a clean build, and both configured Playwright projects. For quicker iteration, build once and select the smallest relevant spec with npx playwright test tests/e2e/<name>.spec.js --project=chromium.

Python mock audit ​

bash
npm run test:mock-removal

This probes whether compatibility mocks can be removed. Use npm run test:mock-removal:list to list candidates. A mock’s presence is not proof that current Frappe requires it; document a failing import or flow before treating it as a runtime dependency.