Testing
| Kind | Where | Runs with | Proves |
|---|---|---|---|
| Unit | plugins/<name>/**/*.spec.ts (Vitest) |
pnpm nx run @antfabric-plugin/<name>:test |
Rules in services, helpers, parsers — with fakes |
| End to end | plugins/<name>/test/*.e2e-spec.ts (Jest) |
pnpm --filter backend test:e2e -- <name> |
The real API, database roles, permissions, events, Temporal |
| Screens | Your eyes, on web, desktop and phone | pnpm dev, pnpm desktop:dev, pnpm mobile:go |
That people can actually use it |
Unit tests
Section titled “Unit tests”Test the service with a fake repository: who may do what, what is refused, what is recorded. Sales’s
sales.service.spec.ts checks that only managers reassign, that Lost needs a reason, that the new
owner is notified but never yourself, and that a failing Chat never undoes a won deal.
Screens: renderPluginScreen from @antfabric/sdk-web/testing renders one as the shells do (a
signed-in person with the permissions you give, your plugin’s context, a fresh query cache);
mockEvents().emit(name, payload) delivers a live event, mockPeople and mockPresence fake the
directory. Keep mockFetch for the API.
End-to-end tests
Section titled “End-to-end tests”A plugin’s end-to-end tests live in its own folder (plugins/<name>/test/), so they travel with the
plugin’s repository. Core’s suite runs them whenever the instance selects the plugin. They import
core only from @antfabric/backend-testing (createApp, DBService, SessionService,
WorkersModule, WorkerRunnerService, TemporalClientService, ContractRegistry,
ScopedPluginContracts, INSTALLED_PLUGINS, runAsJob), never from core’s paths. See
Plugin repositories.
They run the real API (createApp()) against a separate database (<POSTGRES_DB>_e2e, migrated
first), Redis, object storage, Mailpit and — when TEMPORAL_ADDRESS is set — Temporal in the namespace <TEMPORAL_NAMESPACE>-e2e
(E2E_TEMPORAL_NAMESPACE overrides it) with a worker in the same process. If workflow tests hang
locally, run once with a fresh E2E_TEMPORAL_NAMESPACE: a shared namespace can keep old worker
versions.
- Create people directly and give them sessions from
SessionService.start; signing in through the API is rate limited. - Use a random run id in names and emails, so runs never collide with data from earlier runs.
- Check what matters to people: who sees the record, who is refused, what reaches the timeline,
what lands in
event_outboxornotification_requests. - Trigger schedules by hand (
client.schedule.getHandle('af/af.sales/reminders').trigger()) instead of waiting for the minute.
What CI runs on a merge request
Section titled “What CI runs on a merge request”nx affected -t lint typecheck type-check test build— only projects your change affectspnpm plugins:check— manifests and the composition lock; with--boot, also builds the API’s and workers’ module graphs with your plugin. That catches a provider your module doesn’t import, or two files importing values from each other (Nest can't resolve dependencies of X (?)), which unit tests that build services by hand never seepnpm api:specand a diff — the committed API spec and client must match the code- The full backend end-to-end suite against Postgres, Redis, RustFS, Temporal and Mailpit services, with core’s instance (Example only), so core never depends on a product plugin