Repository navigation
feat(test): add @zigordev/test with a real postgresql per test file - #64
Merged
Merged
Conversation
Step 4.1 of the build plan. Every service needs the same two things for its API tests: a real PostgreSQL 18, and test files that never see each other's rows. The package starts one container per run through Testcontainers, migrates a template database once, and gives each test file its own copy. Its app harness builds an app once per file, captures its log lines, and checks an error answer against the platform's format. Tests that need a container live in files named *.db.test.ts, in a Vitest project of their own named <name>:db. pnpm check runs them, and pnpm check:quick, which the push hook runs, leaves them out, as the test rules ask. Testcontainers 12.2.2 brings glob 10.5.0 through archiver-utils, with the flaw GHSA-3g3m-2fjr-6pw4. Record 0033 applies: no release of Testcontainers asks for a fixed version yet, so glob is replaced under overrides at 14.0.6. The package stays private.
zigordev
marked this pull request as ready for review
November 23, 2026 14:19
zigordev
enabled auto-merge (squash)
November 23, 2026 14:19
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.
What
Step 4.1 of the build plan: the new package
@zigordev/test, private for now.@zigordev/test/postgres: one PostgreSQL 18 container per test run, started through Testcontainers. A global setup migrates a template database once, anduseTestDatabase()gives each test file its own copy, dropped after the file.@zigordev/test/app: the harness for API tests.useApp()builds an app once per file and closes it after.captureLogs()keeps the log lines and finds events.expectProblem()checks an error answer: the status,application/problem+json, the code, and exactly the fields of the platform's error format.*.db.test.ts, in a Vitest project named<name>:dbfrom avitest.db.config.ts.pnpm checkruns them.pnpm check:quick, which the push hook runs, now leaves them out with--project '!*:db'.Why
The test rules ask for API tests on a real PostgreSQL, and for every test file to get its own copy of the migrated database. Without one shared package, each service would write its own container start, copies and clean-up. Steps 4.2 and 4.3 build on it.
The override, and the owner's exception
Testcontainers 12.2.2, the newest release, brings
glob10.5.0 througharchiver7 andarchiver-utils, with the flaw GHSA-3g3m-2fjr-6pw4, medium, published 2026-10-30. Record 0033 was followed in its order:archiver. It was still open on 2026-11-23.archiverwhen it starts: an override that removed it failed every test withMODULE_NOT_FOUND.archiver8 dropsarchiver-utils, but bringsminimatch10.2.6, which has its own flaw, GHSA-g3hv-75wg-m249.archiver-utils>glob: 14.0.6underoverrides.pnpm auditthen finds nothing, and every test passes.This is an exception to the one-month rule.
glob14 is a new major version, first released on 2026-10-27, so the override would have waited until 2026-11-27. On 2026-11-23 the owner was asked "Let toolkit#64 wait until 2026-11-27, keeping the one-month rule?" and answered, in their words: "Merge it now".Why the risk is low: Testcontainers uses
archiver, and through itglob, only to copy files into a container, which nothing here does. Every test of the package passes withglob14, on this Mac and in CI.When the line goes: when a release of Testcontainers drops
archiver. From 2026-11-27 it is no longer an exception. The README of@zigordev/testand the new table "The overrides in force" on the handbook page Dependency updates both say so.How it was tested
pnpm checkpasses: 665 tests, 99.3% of lines covered, in 29 seconds on this Mac with Docker Desktop.preparedoes not block a copy, and that a failingpreparestops its container.vitest list --project '!*:db'lists 536 tests and none from a*.db.test.tsfile.expectProblemon an answer. That trial found that Testcontainers also needsprotobufjs: falseunderallowBuilds, and the README now names all three.Observability
Nothing runs in production. A test run starts one PostgreSQL container and Testcontainers' clean-up container, and both are removed when the run ends.
Docs
packages/test/README.md, with the five headings.docs/handbook/tests.md, listed as page 14 of the reading order.CLAUDE.md: the new folder, and whatcheck:quickleaves out.docs/handbook/dependency-updates.md: a table of the overrides in force, and when each goes.Follow-ups
archiver.@zigordev/testneeds three lines underallowBuildsand, until then, the override line. The README says so.