Unit Tests
Unit tests live alongside source files with the*.test.ts suffix.
| Pattern | *.test.ts next to the source file |
| Runner | Bun test (bun test) |
| Command | bun run unit |
| Per-package | bun nx test <package> |
Integration Tests
Integration tests exercise the full stack — API endpoints, authentication flows, database operations, and the content lifecycle.| Requires | Docker Compose services (PostgreSQL, Redis, MinIO) |
| Command | bun run integration |
CI Gates
The CI pipeline runs three sequential stages. All must pass before a PR can be merged.
The combined command that runs all three stages:
ci:required automatically before every push.
Writing Tests
Follow these principles when adding tests:- Write the failing test first. Verify it actually fails before writing any implementation.
- Implement until the test passes. Do not modify the test to make it pass — fix the implementation.
- Test behavior, not implementation details. Assert on observable outcomes (return values, side effects, API responses), not internal state.
- Keep tests focused. Each test should verify one behavior. Use descriptive test names that explain the expected behavior.
Database Migrations
MDCMS uses Drizzle ORM for database schema management. Migrations are generated from the schema definition and applied via Drizzle Kit.Review the generated SQL
Open the generated file in
drizzle/ and verify the SQL matches your intent. Pay attention to destructive operations like column drops or type changes.Test with existing data
Verify the migration works correctly against a database that already has data. Check that existing records are preserved and new constraints do not cause failures.