Skip to content

Support consistent transactional tests across Jest, Vitest, and database clients - #1

Merged
RolandSall merged 8 commits into
mainfrom
codex/cross-runner-data-tests
Sep 11, 2026
Merged

RolandSall merged 8 commits into
mainfrom
codex/cross-runner-data-tests

Conversation

@RolandSall

@RolandSall RolandSall commented Sep 6, 2026 •

Copy link
Copy Markdown
Owner

Database integration tests can now use the same file declaration and typed transaction context under Jest and Vitest, with Prisma, pg, or TypeORM. The existing decorator, lifecycle manager, adapter contract, Vitest configuration signature, and package entrypoints remain available.

Each test attempt holds one rollback-only transaction across its fixtures, body, and teardown. The Jest Node environment integrates through public Circus events and a sandbox-local bridge. Shared session handling bounds acquisition and rollback, invalidates completed contexts, and keeps cleanup errors visible even for expected-failure tests and retries. TypeORM uses a dedicated QueryRunner and transaction-bound EntityManager.

Shared database migrations run once before workers. prepareDatabase is explicitly documented as a per-file hook. The complete NestJS inventory example lives in this repository alongside the smaller examples. It includes versioned application migrations, explicit provider overrides, both runners, all supported clients, and handwritten pg baselines. The README leads with the published @integration-testing/testcontainers package and also documents external databases and SQLite.

Examples are not shipped to npm. Only packages/data is published, with compiled outputs, declarations, README, license, and package metadata. Package checks reject example, migration, and vendor paths and verify that a core-only consumer does not install NestJS. The consumer gate copies the repository example to a temporary directory outside the workspace and installs a freshly packed library artifact. It no longer clones or depends on a separate demo repository.

Validation: 25 unit tests; 42 child-process lifecycle cases on current runners and another 42 with Jest 30.1.0; ESM/CommonJS runtime and declaration checks; optional dependency independence; eight real runner/client/database combinations; 38 intentionally failing database processes with nonzero exit and independent rollback verification; external URL and separate-schema coverage. The relocated example also passes local SQLite execution and the installed-package consumer matrix. CI passed for commit 9dd69ea.

The prepared candidate remains 0.1.0-beta.0; npm returned package-not-found when the candidate version was selected. No npm publication is performed. HTTP requests, unrelated connections, background workers, explicit commits, and concurrent tests within a file remain outside the rollback guarantee; runner timeouts do not forcibly cancel JavaScript.

@RolandSall
RolandSall merged commit b7b1271 into main Sep 11, 2026
1 check passed
@RolandSall
RolandSall deleted the codex/cross-runner-data-tests branch September 11, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant