@lunora/testing 1.0.0-alpha.32 → 1.0.0-alpha.320
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/README.md +27 -3
- package/dist/index.d.mts +974 -197
- package/dist/index.d.ts +974 -197
- package/dist/index.mjs +1 -2
- package/dist/packem_shared/agentHarness-BM24QFnh.mjs +1 -0
- package/dist/packem_shared/containsScorer-DoLfFOs6.mjs +2 -0
- package/dist/packem_shared/createArtifactsFake-L0tjki11.mjs +1 -0
- package/dist/packem_shared/createFakeSecretValues-BTNOscqQ.mjs +1 -0
- package/dist/packem_shared/createStreamGate-Geg-yvx6.mjs +1 -0
- package/dist/packem_shared/evaluationAttributes-CYLgTP1P.mjs +1 -0
- package/dist/packem_shared/groundednessScorer-kgXJCZDg.mjs +3 -0
- package/dist/packem_shared/lunoraTest-KJJjjDCt.mjs +1 -0
- package/dist/playwright.d.mts +126 -0
- package/dist/playwright.d.ts +126 -0
- package/dist/playwright.mjs +1 -0
- package/package.json +25 -5
- package/dist/packem_shared/lunoraTest-DO9gV_fa.mjs +0 -433
package/README.md
CHANGED
|
@@ -109,13 +109,31 @@ Each `lunoraTest(...)` opens an in-memory SQLite database; call `t.close()`
|
|
|
109
109
|
Pass a `fetch` option to replace the throwing stub in action contexts:
|
|
110
110
|
|
|
111
111
|
```ts
|
|
112
|
-
const fakeFetch = vi.fn<typeof globalThis.fetch>()
|
|
112
|
+
const fakeFetch = vi.fn<typeof globalThis.fetch>(async () => Response.json({ ok: true }));
|
|
113
113
|
const t = lunoraTest(schema, { fetch: fakeFetch });
|
|
114
114
|
// ctx.fetch inside any action now calls fakeFetch
|
|
115
115
|
```
|
|
116
116
|
|
|
117
117
|
Without the option, `ctx.fetch` still throws the v1 error on first access.
|
|
118
118
|
|
|
119
|
+
#### Injectable `ctx.services`
|
|
120
|
+
|
|
121
|
+
Pass a `services` option with a fake per `lunora.config` service an action calls
|
|
122
|
+
(`{ documentParser: { fetch } }`). See the [package docs](https://lunora.sh/docs/packages/testing#injectable-ctxservices)
|
|
123
|
+
for an example.
|
|
124
|
+
|
|
125
|
+
#### Recording `ctx.queues`, `ctx.topics` and `ctx.notify` / `ctx.push`
|
|
126
|
+
|
|
127
|
+
Pass `queues` / `topics` (the queue and topic export names from
|
|
128
|
+
`lunora/queues.ts`) and/or `notify` (the `lunora/notify.ts` default export).
|
|
129
|
+
Sends are recorded instead of delivered, and read back with
|
|
130
|
+
`t.queues.sent(name)` / `t.topics.published(name)` / `t.notify.sent(channel)`. See the
|
|
131
|
+
[package docs](https://lunora.sh/docs/packages/testing#queues) for details.
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const t = lunoraTest(schema, { notify, queues: ["jobs"], topics: ["signups"] });
|
|
135
|
+
```
|
|
136
|
+
|
|
119
137
|
#### Fixed `ctx.now`
|
|
120
138
|
|
|
121
139
|
Pass a `now` option (epoch ms) to pin `ctx.now` across every context, so
|
|
@@ -167,8 +185,14 @@ The virtual clock is **per-harness** — advancing one harness's clock does not
|
|
|
167
185
|
affect other harnesses, so tests running in parallel are isolated.
|
|
168
186
|
|
|
169
187
|
Provide a `functions` map (`{ "path:name": registeredFn }`) so the scheduler
|
|
170
|
-
can dispatch jobs.
|
|
171
|
-
|
|
188
|
+
can dispatch jobs. A path not in the map fails the job with `FUNCTION_NOT_FOUND`,
|
|
189
|
+
which then walks the retry budget into `t.scheduler.failures()` — matching
|
|
190
|
+
production, where the DO fires the job at the Worker and dead-letters it.
|
|
191
|
+
|
|
192
|
+
A retryable failure is re-enqueued silently, so `failures()` only fills once the
|
|
193
|
+
whole backoff schedule (~930s of virtual clock) has elapsed — and at that point
|
|
194
|
+
`advance()`/`runPending()` re-throw the failure by default. Pass
|
|
195
|
+
`{ throwOnError: false }` to inspect `failures()` instead.
|
|
172
196
|
|
|
173
197
|
#### Subscription testing
|
|
174
198
|
|