@luckystack/test-runner 0.8.3 → 0.8.4
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.
- package/CHANGELOG.md +6 -0
- package/CLAUDE.md +6 -6
- package/README.md +1 -1
- package/docs/rate-limit-tests.md +5 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.4] - 2026-08-17
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Documented the fail-closed `/_test/reset` contract accurately: exact development/test mode plus required token, default Redis session namespaces only, and no application-DB or custom-SessionAdapter cleanup.
|
|
15
|
+
|
|
10
16
|
## [0.7.4] - 2026-07-22
|
|
11
17
|
|
|
12
18
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -19,7 +19,7 @@ Generated-type-driven test layers voor LuckyStack APIs. Walkt elke endpoint uit
|
|
|
19
19
|
- Voor unit tests van pure functions binnen `_api/*` — gebruik vitest/jest direct, niet deze runner.
|
|
20
20
|
- Voor frontend-UI tests — gebruik Playwright/`webapp-testing` skill, deze runner is server-only.
|
|
21
21
|
- Wanneer er geen generated `apiMethodMap` beschikbaar is (project gebruikt geen `@luckystack/devkit`).
|
|
22
|
-
- Wanneer de target server productie is — fuzz/rate-limit layers maken honderden requests en `/_test/reset`
|
|
22
|
+
- Wanneer de target server productie is — fuzz/rate-limit layers maken honderden requests en `/_test/reset` bestaat alleen bij exact `NODE_ENV=development|test` plus een verplicht `TEST_RESET_TOKEN`.
|
|
23
23
|
- Voor sync-event testing via de auto-sweep — die walkt momenteel alleen API endpoints, niet de sync map (sync support voor de auto-layers staat op de roadmap maar is nog niet geleverd). Layer 5 (`runCustomTests` / `<name>_v<N>.tests.ts`) ondersteunt al wél sync routes via per-route testfiles naast `_sync/` sources.
|
|
24
24
|
|
|
25
25
|
## Function Index
|
|
@@ -39,7 +39,7 @@ Generated-type-driven test layers voor LuckyStack APIs. Walkt elke endpoint uit
|
|
|
39
39
|
| `runRateLimitTests({ apiMethodMap, apiMetaMap, baseUrl, skip?, inputFor?, headers?, maxRateLimitToTest?, resetBetweenEndpoints?, resetToken?, onResult? })` | Sweep alle `rateLimit: N` endpoints | → docs/rate-limit-tests.md |
|
|
40
40
|
| `runFuzzCheck({ endpoint, baseUrl, headers? })` | Single-endpoint crash-resistance fuzz | → docs/fuzz-tests.md |
|
|
41
41
|
| `runFuzzTests({ apiMethodMap, baseUrl, skip?, headers?, onResult? })` | Sweep fuzz layer (nightly CI) | → docs/fuzz-tests.md |
|
|
42
|
-
| `resetServerState({ baseUrl, token? })` | POST naar `/_test/reset` om
|
|
42
|
+
| `resetServerState({ baseUrl, token? })` | POST naar `/_test/reset` om rate limits + standaard Redis-sessienamespaces te wissen; niet app-DB/custom adapters | → docs/rate-limit-tests.md |
|
|
43
43
|
| `resolveTestBaseUrl({ cwd?, fallbackUrl? })` | Resolves `TEST_BASE_URL` → actually-bound dev port advertisement → caller fallback, so an auto-hop does not create false connection failures. | → docs/contract-tests.md |
|
|
44
44
|
| `resolveTestEnvironment({ loadProjectConfig? })` | Laadt `.env`-lagen en resolveert optionele secret-manager-pointers in het testproces vóór DB/Redis-backed Layer-5 modules importeren. | → docs/contract-tests.md |
|
|
45
45
|
| `sampleSchemaInput(schema, options?)` | Genereert Zod-valid sample payload uit een schema. `options.stringPrefix` tagt UNCONSTRAINED strings (finding #98) — format/checked strings blijven ongeprefixt zodat ze valid blijven. | → docs/contract-tests.md |
|
|
@@ -80,7 +80,7 @@ Generated-type-driven test layers voor LuckyStack APIs. Walkt elke endpoint uit
|
|
|
80
80
|
|
|
81
81
|
- `TEST_BASE_URL` (env, test process) — explicit target override consumed first by `resolveTestBaseUrl`; otherwise it reads `node_modules/.luckystack/dev-server.json` and then uses the supplied config-derived fallback.
|
|
82
82
|
- `RunAllTestsInput.loadProjectConfig` / `RunCustomTestsInput.loadProjectConfig` — verplichte lazy loader voor de default export van consumer `config.ts`. De runner laadt eerst `.env`/`.env.local`, leest daarna deze config en draait bij een niet-lege `secretManager.url` `initSecretManager({...config, source:'remote'})` vóór custom test imports. `runAllTests` doet dit één keer voor alle lagen; directe Layer-5-calls doen het zelf. Een ontbrekende loader of geconfigureerd-maar-ontbrekende secret-manager is een harde fout.
|
|
83
|
-
- `NODE_ENV` (env, server-side) — `/_test/reset` is
|
|
83
|
+
- `NODE_ENV` (env, server-side) — `/_test/reset` is alleen beschikbaar bij exact `development` of `test`.
|
|
84
84
|
- `TEST_RESET_TOKEN` (env, optional, server-side) — wanneer gezet moet `resetServerState({ token })` deze meesturen als `X-Test-Reset-Token`. Verplicht voor staging/preview deploys die het endpoint over het netwerk exposen.
|
|
85
85
|
- `RunRateLimitTestsInput.maxRateLimitToTest` (default `50`) — endpoints met hogere `rateLimit` worden geskipt om duizenden requests in CI te vermijden.
|
|
86
86
|
- `RunRateLimitTestsInput.resetBetweenEndpoints` (default `false`) — hit `/_test/reset` voor elke endpoint zodat het shared IP-bucket schoon is.
|
|
@@ -91,10 +91,10 @@ Generated-type-driven test layers voor LuckyStack APIs. Walkt elke endpoint uit
|
|
|
91
91
|
|
|
92
92
|
## Peer dependencies
|
|
93
93
|
|
|
94
|
-
- **Required**: `zod@^4.0.0` (peer), `socket.io-client@^4.8.0` (peer — `streamWatcher.ts` opent een tweede socket voor `ctx.watchStream`), `@luckystack/core
|
|
95
|
-
- **Required server-side**: `@luckystack/server` met `/_test/reset`
|
|
94
|
+
- **Required**: `zod@^4.0.0` (peer), `socket.io-client@^4.8.0` (peer — `streamWatcher.ts` opent een tweede socket voor `ctx.watchStream`), `@luckystack/core` (direct runtime dependency — levert de helpers die de runner consumeert: `tryCatch`/`tryCatchSync`, `getProjectConfig`/`getCsrfConfig`, `getSrcDir` (default src-dir voor custom-test discovery in `customTests.ts`), `getPrismaClient` (Layer-5 `ctx.prisma`) en `clearAllRateLimits`. De `apiMethodMap` zelf wordt door de consumer als argument doorgegeven, niet uit een pad gelezen).
|
|
95
|
+
- **Required server-side**: `@luckystack/server` met `/_test/reset` gemount, exact `NODE_ENV=development|test`, en een niet-lege `TEST_RESET_TOKEN`.
|
|
96
96
|
- **Required generated artefact**: `apiMethodMap.generated.ts` (en `apiMetaMap.generated.ts` voor de auth/rate-limit layers), geproduceerd door `@luckystack/devkit`.
|
|
97
|
-
- **Optional**: `@luckystack/secret-manager@^0.
|
|
97
|
+
- **Optional**: `@luckystack/secret-manager@^0.8.4` (optional peer) — alleen dynamisch geladen wanneer `loadProjectConfig` een niet-lege `config.secretManager.url` teruggeeft. Zonder secret-managerconfig blijft de runner een gewone lokale-env flow.
|
|
98
98
|
|
|
99
99
|
## Related
|
|
100
100
|
|
package/README.md
CHANGED
|
@@ -52,7 +52,7 @@ The fuzz layer is intentionally exhaustive and slow — wire it into nightly CI
|
|
|
52
52
|
|
|
53
53
|
## Server hooks it depends on
|
|
54
54
|
|
|
55
|
-
- `/_test/reset` endpoint — served by `@luckystack/server`
|
|
55
|
+
- `/_test/reset` endpoint — served by `@luckystack/server` only when `NODE_ENV` is exactly `development` or `test`, and always gated by a non-empty `TEST_RESET_TOKEN`. `resetServerState` clears framework rate-limit state plus the default Redis session/active-user namespaces; it does not clear application database rows or custom `SessionAdapter` stores.
|
|
56
56
|
- `apiMethodMap.generated.ts` — produced by `@luckystack/devkit` from your `_api/*` files. Defaults are read via `getApiMethodMapPath()` from `@luckystack/core`.
|
|
57
57
|
|
|
58
58
|
## Public API
|
package/docs/rate-limit-tests.md
CHANGED
|
@@ -69,7 +69,7 @@ Behavior notes:
|
|
|
69
69
|
|
|
70
70
|
### `resetServerState(input)`
|
|
71
71
|
|
|
72
|
-
POST to the server's `/_test/reset` endpoint. Used between rate-limit probes and at
|
|
72
|
+
POST to the server's `/_test/reset` endpoint. Used between rate-limit probes and at CI bookends to clear framework-owned limiter/default-session state; it is not a general application-database reset.
|
|
73
73
|
|
|
74
74
|
Signature:
|
|
75
75
|
|
|
@@ -84,7 +84,7 @@ interface ResetServerStateInput {
|
|
|
84
84
|
|
|
85
85
|
Returns `true` when the server responds 2xx, `false` on network error, parse error, or non-2xx. The error is swallowed deliberately — the most common reason for `false` is "the route is disabled in this environment", and the caller usually wants to proceed anyway.
|
|
86
86
|
|
|
87
|
-
URL: `${baseUrl}/_test/reset` (POST).
|
|
87
|
+
URL: `${baseUrl}/_test/reset` (POST). Supply `token` (normally `TEST_RESET_TOKEN`); the request sends it as `X-Test-Reset-Token`. The server always requires a non-empty matching value.
|
|
88
88
|
|
|
89
89
|
## `/_test/reset` server contract
|
|
90
90
|
|
|
@@ -98,7 +98,7 @@ Gating, in order:
|
|
|
98
98
|
What it clears (when both gates pass):
|
|
99
99
|
|
|
100
100
|
- **All rate-limit buckets** via `clearAllRateLimits()` from `@luckystack/core`. Every key under the rate-limit Redis namespace is dropped. Always cleared.
|
|
101
|
-
- **
|
|
101
|
+
- **Default Redis session namespaces** matching `formatKey('-session', '') + ':*'` and `formatKey('-activeUsers', '') + ':*'`. They are scanned in batches of 200 and follow the registered Redis key formatter.
|
|
102
102
|
- **Registered runtime hooks** when `?include=hooks` is in the query string. NOT included by default because framework-internal handlers (e.g. presence postLogout) register at boot — clearing them would require a server restart to recover.
|
|
103
103
|
|
|
104
104
|
Response:
|
|
@@ -109,6 +109,8 @@ Response:
|
|
|
109
109
|
|
|
110
110
|
The `cleared` array reflects what actually had keys to drop. It is informational; `runRateLimitTests` only checks `response.ok`.
|
|
111
111
|
|
|
112
|
+
> **Storage boundary:** the endpoint does not call `SessionAdapter`. A custom DynamoDB/Postgres/in-memory session store survives this reset, as do application database rows. Tests using custom storage must clear it explicitly in their own setup/teardown.
|
|
113
|
+
|
|
112
114
|
## Types
|
|
113
115
|
|
|
114
116
|
```ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luckystack/test-runner",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -54,11 +54,11 @@
|
|
|
54
54
|
"test": "vitest run"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@luckystack/core": "^0.8.
|
|
57
|
+
"@luckystack/core": "^0.8.4"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
|
-
"@luckystack/login": "^0.8.
|
|
61
|
-
"@luckystack/secret-manager": "^0.8.
|
|
60
|
+
"@luckystack/login": "^0.8.4",
|
|
61
|
+
"@luckystack/secret-manager": "^0.8.4",
|
|
62
62
|
"socket.io-client": "^4.8.0",
|
|
63
63
|
"zod": "^4.0.0"
|
|
64
64
|
},
|