2.2 KiB
2.2 KiB
api-host-testing-kit — Populate Stage-5 ./testing subpath
Why
@suaveplan/api-host/testing has shipped a STAGE_2_RESERVED sentinel since Stage 2. Stage 5 in-memory adapters (api-router-in-memory, api-auth-static-principal / api-auth-anonymous, api-db-sqlite-memory, api-events-in-memory, api-ws-broker-in-memory, api-tenant-provider-memory, api-secrets-env) have all shipped, but no host-side composition surface drives them together. Plugin authors writing integration tests have to hand-wire every adapter slot at the call site — the same boilerplate observed in e2e/foundation-stack/src/server.ts. The keystone for the Stage-5 testing kit is a createTestHost(config?) factory that composes every default in one line.
What changes
- Replace
STAGE_2_RESERVEDplaceholder with the fullcreateTestHost(config?)factory undersrc/testing/create-test-host/. - Surface flips: the sentinel constant changes from
truetofalse(back-compat preserved — consumers that branched on=== truestill compile; the populated helpers ship alongside). - New types:
TestHostConfig,TestHostSeed,TestHostAdapters,TestHost,FixturePluginInstall,FixtureRouteRegistration. TestHostextendsHostwithinstallFixturePlugin,fetchAs,waitForEvent,dispose.- Default adapter resolution per-slot, override-beats-default semantics.
seed.principal/seed.tenants/seed.secretspopulate the default adapter inputs.- Companion smoke at
e2e/foundation-stack-test-host/boots a Bun.serve overcreateTestHost(...)and drives every wired slot through real HTTP with Playwright. suaveplan.conformanceSkipfor api-lifecycle / api-loader / api-manifest / api-secrets retained (api-host is the consumer/driver, not the implementer); the gap is documented in README + this proposal.
Impact
- Affected specs:
api-host - Affected code:
packages/api-stack/api/api-host/src/testing/*,packages/api-stack/api/api-host/package.json(peerDependenciesMeta + new devDependencies for the in-memory adapters),e2e/foundation-stack-test-host/*(new workspace). - Affected downstream: every package previously branching on
STAGE_2_RESERVED === truecan now opt into the populated helper; no breaking change.