Shared unit-test rules live in unittests.md. Frontend (UI) tests follow extensions-ui-testing-best-practices.md.
Shared build and target knowledge also applies:
This file documents only repository-specific testing behavior.
The current test scope covers:
- backend app route registration for API, event, and plug routes
- agreement API handlers
- order and agreement event handlers
- order and agreement pipeline execution
- pipeline step logging behavior
- frontend plug components, hooks, and shared model helpers
Use the repository make targets:
make test
make check
make check-allRepository command mapping:
make testruns backendpytestand frontendjestmake test scope=backendruns backendpytestmake test scope=frontendruns frontendnpm testmake checkruns backend formatting/lint/type/lock checks and frontend TypeScript/ESLint checksmake check scope=backendrunsruff format --check,ruff check,flake8,mypy, anduv lock --checkmake check scope=frontendrunstsc --noEmitandeslintmake check-allruns checks, tests, frontend build, and metadata generation/validation forscope=all
The CI workflow in .github/workflows/pr-build-merge.yml uses the same make build and make check-all flow, and additionally runs a SonarCloud/SonarQube scan (SONAR_TOKEN) as a quality gate that can block the pull request.
Repository-specific test settings come from backend/pyproject.toml:
- tests are discovered under
tests pythonpathincludes the repository root- coverage is collected for
mpt_extension_python_template - tests run with
--import-mode=importlib
Repository-specific guidance:
- Use fixtures from
backend/tests/conftest.pywhere possible. - Mock external Marketplace SDK calls rather than calling real services.
- Keep tests focused on the behavior of the extension layer, not on internals of
mpt-extension-sdkitself. - Keep frontend tests close to the component, hook, or model module they cover.
- Use generated devmock payloads only as stable examples; do not depend on live Marketplace services.
- Follow the shared unit-test standard for AAA structure, parametrization, mocking rules, deterministic behavior, and coverage expectations.
Frontend tests run with Jest + Testing Library (make test scope=frontend).
Repository-specific patterns:
- Co-locate tests with the module they cover (
App.test.tsx,*.test.tsnext to the component, hook, or model underfrontend/src/). - Mock the SDK HTTP client (
httpfrom@mpt-extension/sdk) instead of hitting a backend; assert on rendered output and load/error states. - Reuse shared fixtures from
frontend/src/shared/test-utils/(for exampleagreement-mocks.ts) rather than redefining agreement payloads. - Render components with Testing Library and query by accessible roles/labels.
Add or update tests when a change modifies:
- API request handling
- event processing
- pipeline step behavior
- plug registration or static asset references
- frontend plug behavior
- command output
- dependency wiring in the extension app
If a change only affects documentation, tests are not required.