Unit Tests
Unit tests live alongside source files with the*.test.ts suffix.
Unit tests cover config parsing, validation logic, contracts, SDK methods, and utility functions. They do not require any external services.
Integration Tests
Integration tests exercise the full stack — API endpoints, authentication flows, database operations, and the content lifecycle.CI Gates
The CI pipeline runs three sequential stages. All must pass before a PR can be merged.1
Quality
Format check + TypeScript typecheck across all packages.
2
Unit tests
All unit tests across every package.
3
Integration tests
Full integration test suite. Requires Docker services.
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.1
Modify the schema
Edit the Drizzle schema file:
2
Generate migration
drizzle/ directory.3
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.4
Apply locally
5
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.
6
Commit together
Commit the schema change and the generated migration file in the same commit: