@stratal/testing 0.0.0-canary-e5681b8 → 0.0.0-canary-99e36c5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/CHANGELOG.md +4 -37
  2. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,45 +1,12 @@
1
1
  # @stratal/testing
2
2
 
3
- ## 0.0.0-canary-e5681b8
4
-
5
- ### Minor Changes
6
-
7
- - e5681b8: Give each test file its own leased database, drain deferred work before a test finishes, and supply the cache and gateway bindings the runtime never populates.
8
-
9
- ### Database isolation
10
- - Give every test **file** its own database, leased from a fixed pool of worker slots rather than created per file. Each file takes the lowest free slot, `<base>_w_<slot>`, and gets a fresh clone of the migrated template in it; the slot frees when the pool disposes the file's isolate. A run therefore holds at most as many databases as it runs files at once, so a long suite no longer piles up one database per file until Postgres runs out of disk mid-run.
11
- - Per-file isolation is deliberate: the Workers test pool isolates storage per file and can run a worker's files concurrently, so any database shared across files corrupts under CI latency. Within a file, tests reset state through `truncateDb` or the reset engine.
12
- - `createTestDatabaseGlobalSetup` accepts a one-time `prepare` hook to bake expensive baseline state — seed data, a default tenant schema — into the template once, so every file's database inherits it through the clone instead of rebuilding it per test.
13
- - `createTestDatabaseGlobalSetup` now returns a teardown, so a run reclaims what it created instead of leaving the leftovers for the next run's setup to find. Consumers pass it to `globalSetup` exactly as before and need no change. The sweep is connection-guarded and skips a slot that is currently leased, so a database cloned but not yet connected to is never dropped by a concurrent process.
14
- - `truncateDb(name?, opts?)` accepts a `ResetOptions` preserve-list; migration tables matching `_prisma%` are always preserved.
15
- - Default database-isolation projects to a 30 second hook timeout, since cloning a template under a full worker slot routinely exceeds Vitest's 10 second default and fails with "Hook timed out in 10000ms". This is a floor, not a ceiling: an explicit `hookTimeout`, `fileParallelism` or `isolate` on the consuming project is now respected instead of being overwritten.
16
- - Share one database pool per connection in the harness and tear it down exactly once. The harness runs against a direct Postgres with no Hyperdrive to multiplex, so a fresh pool per resolution accumulated until parallel files exhausted the server's connection limit with "sorry, too many clients already". Disposing a connection no longer logs "Called end on pool more than once".
17
-
18
- ### Bindings and lifecycle
19
- - Supply the `ctx.cache` binding so cache-decorated routes are testable with no configuration. Neither Miniflare nor workerd populates it, so without this a single `@Cacheable` or `@PurgesCache` route would fail an app's entire suite on the first request. `Test.createTestingModule()` installs a stub by default: `@Cacheable` routes return real `Cache-Control` and `Cache-Tag` headers, and purges succeed, recording each `PurgeSpec` in call order on `module.cache.purges`. Pass `cache: false` to opt back into the unconfigured runtime.
20
- - Supply a `ctx.exports` stub by default so adopting the response-cache gateway does not break existing suites. Assert forwarded requests and their resolved partitions through `module.gateway.loopbacks`. The stub answers to any export name, so a passing suite is not what proves your configured entrypoint is correct — the type check against your Worker's exports is.
21
- - Drain work a request defers through `ctx.waitUntil` before `fetch()` resolves, mirroring the Workers runtime. A non-blocking listener's deferred database write previously stayed in flight past the response and could still be running at the next request or at teardown, where disposing that resource hung the suite past the hook timeout.
22
- - Drain deferred work in `close()` before tearing the app down. `fetch()` already drained per call, but the websocket, SSE and Quarry helpers share the same queue, so a suite using only those could reach teardown with writes still in flight and race the connection pool's disposal.
23
-
24
- ### Testing surface
25
- - `Test.createTestingModule()` accepts `trailingSlash` and `versioning` and passes both to the `Application` it builds, taking the same shapes as on the `Stratal` constructor. A testing module never runs the app's entry file, so an app configuring either there previously had it in production only — its suite asserted URL shapes that configuration would never emit. Both stay unset by default.
26
- - Support `head()`, `list()` and `deleteMany()` in fake storage, so the new storage methods are exercisable without R2. `list()` returns **one object per page** unless a `limit` is passed, so a caller that ignores `cursor` fails in tests instead of undercounting against a real bucket, and `contentType` and `metadata` are omitted unless `includeMetadata: true`, matching what R2 returns.
27
- - Stop `module.inertia` sending a hard-coded `X-Inertia-Version`. It sent `'1'`, so any app configuring a real asset version had every request read as a stale client and answered with a 409 — an entire Inertia suite failing on a value the tests never chose. A test that wants the mismatch path can ask for it with `module.inertia.withHeaders({ 'X-Inertia-Version': 'stale' })`.
28
- - Fix chunked uploads to the fake storage service failing with `ReadableStream is disturbed` when the body is a single-use stream, which is the shape a chunked upload delivers.
29
- - Keep `stratalTest()` typed against a single Vite instance. Vitest and `@stratal/inertia` resolved two different copies, which surfaced as a `Plugin` that would not assign to `Plugin`, an "excessive stack depth" comparison, and a missing `test` key on `UserConfig`.
30
-
31
- ### Breaking Changes
32
- - **There is now a single database isolation model.** The `shared` and `database` isolation toggle is gone, along with the `isolation` option on both `stratalTest({ database })` and `createTestDatabaseGlobalSetup`. Pass `stratalTest({ database: {} })` to enable isolation and delete any `isolation:` option.
33
- - **`stratalTest({ database })` now requires `isolate: true`** and throws on `isolate: false`.
34
- - **`createTestDatabaseGlobalSetup` now requires `schema`.** Add it if you were relying on the previous default.
35
- - **`@cloudflare/vitest-pool-workers` is now `@cloudflare/vitest-plugin`.** Update the dependency, any direct import of it, and the `types` entry in your test `tsconfig.json`. `npx @cloudflare/codemods vitest:pool-workers-to-vitest-plugin` does all three. A config that only calls `stratalTest()` needs no change beyond the dependency. `stratalTest()` and its options are unchanged, and the integration supports Vitest 4.1 and later.
3
+ ## 0.0.0-canary-99e36c5
36
4
 
37
5
  ### Patch Changes
38
6
 
39
- - Updated dependencies [e5681b8]
40
- - Updated dependencies [e5681b8]
41
- - stratal@0.0.0-canary-e5681b8
42
- - @stratal/framework@0.0.0-canary-e5681b8
7
+ - Updated dependencies [df54f36]
8
+ - stratal@0.0.0-canary-99e36c5
9
+ - @stratal/framework@0.0.0-canary-99e36c5
43
10
 
44
11
  ## 0.1.0
45
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratal/testing",
3
- "version": "0.0.0-canary-e5681b8",
3
+ "version": "0.0.0-canary-99e36c5",
4
4
  "description": "Testing utilities and mocks for Stratal framework applications",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -89,10 +89,10 @@
89
89
  },
90
90
  "peerDependencies": {
91
91
  "@better-auth/core": ">=1.6",
92
- "@stratal/framework": "0.0.0-canary-e5681b8",
92
+ "@stratal/framework": "0.0.0-canary-99e36c5",
93
93
  "better-auth": ">=1.4",
94
94
  "pg": "^8.0.0",
95
- "stratal": "0.0.0-canary-e5681b8",
95
+ "stratal": "0.0.0-canary-99e36c5",
96
96
  "vitest": "^4.1.0"
97
97
  },
98
98
  "peerDependenciesMeta": {
@@ -112,14 +112,14 @@
112
112
  "devDependencies": {
113
113
  "@better-auth/core": "^1.7.5",
114
114
  "@cloudflare/workers-types": "5.20260919.1",
115
- "@stratal/framework": "0.0.0-canary-e5681b8",
115
+ "@stratal/framework": "0.0.0-canary-99e36c5",
116
116
  "@types/node": "^26.6.2",
117
117
  "@types/pg": "^8.23.1",
118
118
  "@vitest/runner": "~4.1.11",
119
119
  "@vitest/snapshot": "~4.1.11",
120
120
  "better-auth": "^1.7.5",
121
121
  "pg": "^8.23.0",
122
- "stratal": "0.0.0-canary-e5681b8",
122
+ "stratal": "0.0.0-canary-99e36c5",
123
123
  "tsdown": "^0.23.0",
124
124
  "typescript": "^7.0.2",
125
125
  "vitest": "~4.1.11"