Validation and tests¶
Before a module can be considered finished, it has to pass the contract validators and ship with tests.
module-doctor¶
It validates the declarative contract:
module.jsonis valid JSON with the required fields (name,version,edition,coreVersionRequired,tablePrefix,apiNamespace).editioniscommunity(modules are never enterprise). Exception: marketplace-stylemodule.jsonfiles (those carryingvendor/isolation/http/didacta, validated by the host's strict schema) do not carryedition— the doctor exempts them and flags the legacyedition/category/requiredLicenseFeaturekeys as errors, since they would break installation withMANIFEST_SCHEMA_INVALID.tablePrefixfollows themod_<slug-in-snake-case>_convention andapiNamespaceis/modules/<slug>.- A
README.mdexists with the 9 mandatory sections. - If the module carries its own Prisma schema, every
@@mapuses the prefix.
The module README¶
The 9 mandatory sections (the canonical example is modules/access-groups/README.md; the section headings are written in Spanish, which is what the doctor checks for):
# mod.mi-modulo
## Edición
## Estado
## Resumen funcional
## Modelo de datos
## API pública
## Eventos
## Configuración
## Dependencias
ee-fence¶
It guarantees the open-core model: no .ee.* file may live under modules/* (every module is Community), and the core's EE files carry the correct license header. It runs in CI and blocks the PR.
Tests¶
- Unit tests in
modules/<slug>/tests/with Vitest — the package's pure logic is tested without infrastructure. This includes acontract.test.tsthat registers the module in a realModuleRegistry(validating manifest + lifecycle). - Minimum 70% coverage on services and handlers (a project rule).
- Integration tests for the host (the ephemeral database from
docker-compose.test.yml), and Playwright E2E tests for the user flow you deliver: if there is no spec for your feature, write one.
pnpm --filter @didacta/mod-mi-modulo test # the package's unit tests
bash scripts/test-local.sh # the full authorised suite
Final checklist¶
- [ ]
pnpm lintandpnpm typecheckgreen. - [ ]
pnpm tsx scripts/ee-fence.tswith no errors. - [ ]
pnpm tsx scripts/module-doctor.ts modules/mi-modulowith no errors. - [ ]
module.jsonandsrc/manifest.tsconsistent with each other. - [ ] Package unit tests + host integration tests + E2E for the flow.
- [ ] A README with the 9 sections.
- [ ] A versioned migration applicable with
migrate deploy(neverdb push).