Add integration test suite with Testcontainers PostgreSQL#37
Merged
aji70 merged 1 commit intoJun 20, 2026
Merged
Conversation
- Add test/integration/setup.ts: boots a real postgres:16 container via
Testcontainers, wires DB env vars, starts the full NestJS app, and
provides clearAll() for per-test table isolation
- Add 3 integration spec files covering 17 assertions total:
users-pagination – default limit, custom limit, cursor pagination,
role/status filter, hasMore flag, name search
user-sessions – signup/login session persistence, token rotation,
logout, logout-all, revoked-token rejection
user-profile-constraints – duplicate email (409), non-unique display
name, profile field persistence, bio max length
- Add test/jest-integration.json Jest config (testTimeout 120 s, serial)
- Add npm run test:integration script (--forceExit)
- Add integration-tests CI job that runs on ubuntu-latest with Docker;
Testcontainers manages its own container lifecycle, no service block needed
- Add "Running integration tests locally" section to README
Contributor
|
@ndii-dev Please fix the CI to pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28
Summary
test/integration/setup.ts— Testcontainers bootstrap: spins up apostgres:16container, sets DB env vars dynamically, starts the full NestJS app, and exportsclearAll()for per-test table isolation. Failed migrations exit fast with a clear error.users-pagination.integration.spec.ts— default limit, custom limit, cursor-based next page (no overlap), role filter, status filter,hasMore: false, name searchuser-sessions.integration.spec.ts— session persistence after signup/login, token rotation (old token revoked), logout, logout-all, revoked-token rejection (401)user-profile-constraints.integration.spec.ts— duplicate email returns 409, non-unique display name allowed,displayName/bio/avatarUrlpersist end-to-end, bio > 300 chars returns 400test/jest-integration.json— separate Jest config (testTimeout: 120 000 ms,maxWorkers: 1)npm run test:integration— added topackage.jsonintegration-testsjob onubuntu-latest(Docker available by default); Testcontainers manages its own container, noservices:block neededTest plan
npm run test:integrationpasses locally with Docker runningintegration-testsjob passes on this PRclearAll()inbeforeEach)