@lunora/testing 1.0.0-alpha.3 → 1.0.0-alpha.300
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/LICENSE.md +6 -0
- package/README.md +39 -3
- package/__assets__/package-og.svg +1 -1
- package/dist/index.d.mts +967 -176
- package/dist/index.d.ts +967 -176
- 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-jk0t_K-w.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 +26 -5
- package/dist/packem_shared/lunoraTest-BUg4Ebv8.mjs +0 -415
package/LICENSE.md
CHANGED
|
@@ -103,3 +103,9 @@ Unless required by applicable law or agreed to in writing, software distributed
|
|
|
103
103
|
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
104
|
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
105
|
specific language governing permissions and limitations under the License.
|
|
106
|
+
|
|
107
|
+
<!-- DEPENDENCIES -->
|
|
108
|
+
<!-- /DEPENDENCIES -->
|
|
109
|
+
|
|
110
|
+
<!-- TYPE_DEPENDENCIES -->
|
|
111
|
+
<!-- /TYPE_DEPENDENCIES -->
|
package/README.md
CHANGED
|
@@ -109,13 +109,43 @@ 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
|
+
|
|
137
|
+
#### Fixed `ctx.now`
|
|
138
|
+
|
|
139
|
+
Pass a `now` option (epoch ms) to pin `ctx.now` across every context, so
|
|
140
|
+
time-dependent handlers are deterministic:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
const t = lunoraTest(schema, { now: 1_700_000_000_000 });
|
|
144
|
+
// ctx.now === 1_700_000_000_000 in every query/mutation/action
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Defaults to the wall clock captured at harness creation.
|
|
148
|
+
|
|
119
149
|
#### Controllable in-memory scheduler
|
|
120
150
|
|
|
121
151
|
`ctx.scheduler` is a fully functional fake. Jobs are enqueued synchronously but
|
|
@@ -155,8 +185,14 @@ The virtual clock is **per-harness** — advancing one harness's clock does not
|
|
|
155
185
|
affect other harnesses, so tests running in parallel are isolated.
|
|
156
186
|
|
|
157
187
|
Provide a `functions` map (`{ "path:name": registeredFn }`) so the scheduler
|
|
158
|
-
can dispatch jobs.
|
|
159
|
-
|
|
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.
|
|
160
196
|
|
|
161
197
|
#### Subscription testing
|
|
162
198
|
|