-
Notifications
You must be signed in to change notification settings - Fork 84
Testing infrastructure — unit and integration test setup #413
Copy link
Copy link
Open
Labels
Description
OverviewnEstablishes the testing foundation that all modules build on. Provides test utilities, mock factories, database helpers, and coverage reporting. Every module must hit 80% coverage before merging.nn## Acceptance Criterian- [ ] jest.config.ts: configure moduleNameMapper for path aliases, collectCoverageFrom for all service files, coverageThreshold (statements/branches/functions/lines all >= 80%), testEnvironment noden- [ ] test/ directory structure: test/unit/ for unit tests (mocked deps), test/integration/ for tests against real Postgres/Redisn- [ ] test/helpers/db.helper.ts: createTestDataSource() — creates TypeORM DataSource connecting to test Postgres; clearDatabase() — truncates all tables between tests; closeDatabase() — closes connectionn- [ ] test/helpers/auth.helper.ts: createTestUser(overrides?) — inserts a User row and returns it with a valid JWT access token; createTestAdmin() — same for admin rolen- [ ] test/helpers/mock.factory.ts: factory functions for all entities: mockUser(), mockWallet(), mockTransfer(), mockPayLink() etc. — return valid entity objects with sensible defaultsn- [ ] test/helpers/request.helper.ts: wraps supertest with auth header injection: authedRequest(app, token).get('/path')n- [ ] Integration test example (Transfers): create two users → provision wallets (mocked Soroban) → POST /transfers → verify Transfer record created + Transaction records for both usersn- [ ] GitHub Actions: pnpm test:cov runs with coverage; post coverage summary as PR comment using jest-coverage-comment actionn- [ ] pnpm test:e2e: runs integration tests against real Postgres (Docker); separate from unit tests in CIn- [ ] Document testing patterns in TESTING.md: when to use unit vs integration, how to mock SorobanService, how to use test helpers
Reactions are currently unavailable