@lunora/testing 1.0.0-alpha.27 → 1.0.0-alpha.28

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/dist/index.d.mts CHANGED
@@ -141,6 +141,19 @@ type FunctionRegistry = Record<string, RegisteredAction<any, any> | RegisteredMu
141
141
  * clearly-throwing stubs for unsupported surfaces.
142
142
  */
143
143
  interface LunoraTestOptions {
144
+ /**
145
+ * Injectable `ctx.env` for every context (query / mutation / action). When
146
+ * provided, handlers that read `ctx.env.SOME_KEY` (the validated `defineEnv`
147
+ * surface) see this object. Left unset it stays `undefined` — matching the
148
+ * optional `ctx.env?` field, so graceful `ctx.env?.KEY` access still yields
149
+ * `undefined` rather than throwing. Not a throwing stub for exactly that
150
+ * reason: `env` is designed to be legitimately absent.
151
+ * @example
152
+ * ```ts
153
+ * const t = lunoraTest(schema, { env: { STRIPE_KEY: "sk_test_…" } });
154
+ * ```
155
+ */
156
+ env?: Record<string, unknown>;
144
157
  /**
145
158
  * Injectable `fetch` implementation for action contexts. When provided,
146
159
  * `ctx.fetch` in every `action` (and `withIdentity` views) resolves to this
@@ -263,6 +276,8 @@ interface TestHarness {
263
276
  *
264
277
  * **v1 surfaces now supported:**
265
278
  *
279
+ * - `ctx.env` (all contexts): inject the validated env via `options.env`; unset it
280
+ * stays `undefined`, matching the optional `ctx.env?` field.
266
281
  * - `ctx.fetch` (actions): inject a custom `fetch` via `options.fetch`.
267
282
  * - `ctx.scheduler` (mutations + actions): fully functional fake with virtual clock;
268
283
  * control via `harness.scheduler.advance(ms)` / `runPending()` / `list()`.
package/dist/index.d.ts CHANGED
@@ -141,6 +141,19 @@ type FunctionRegistry = Record<string, RegisteredAction<any, any> | RegisteredMu
141
141
  * clearly-throwing stubs for unsupported surfaces.
142
142
  */
143
143
  interface LunoraTestOptions {
144
+ /**
145
+ * Injectable `ctx.env` for every context (query / mutation / action). When
146
+ * provided, handlers that read `ctx.env.SOME_KEY` (the validated `defineEnv`
147
+ * surface) see this object. Left unset it stays `undefined` — matching the
148
+ * optional `ctx.env?` field, so graceful `ctx.env?.KEY` access still yields
149
+ * `undefined` rather than throwing. Not a throwing stub for exactly that
150
+ * reason: `env` is designed to be legitimately absent.
151
+ * @example
152
+ * ```ts
153
+ * const t = lunoraTest(schema, { env: { STRIPE_KEY: "sk_test_…" } });
154
+ * ```
155
+ */
156
+ env?: Record<string, unknown>;
144
157
  /**
145
158
  * Injectable `fetch` implementation for action contexts. When provided,
146
159
  * `ctx.fetch` in every `action` (and `withIdentity` views) resolves to this
@@ -263,6 +276,8 @@ interface TestHarness {
263
276
  *
264
277
  * **v1 surfaces now supported:**
265
278
  *
279
+ * - `ctx.env` (all contexts): inject the validated env via `options.env`; unset it
280
+ * stays `undefined`, matching the optional `ctx.env?` field.
266
281
  * - `ctx.fetch` (actions): inject a custom `fetch` via `options.fetch`.
267
282
  * - `ctx.scheduler` (mutations + actions): fully functional fake with virtual clock;
268
283
  * control via `harness.scheduler.advance(ms)` / `runPending()` / `list()`.
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { lunoraTest } from './packem_shared/lunoraTest-CHrCQgOO.mjs';
1
+ export { lunoraTest } from './packem_shared/lunoraTest-DO9gV_fa.mjs';
2
2
  export { extractLink, listCapturedMail, waitForMail } from '@lunora/mail/testing';
@@ -316,6 +316,7 @@ const lunoraTest = (schema, options) => {
316
316
  const queryContext = {
317
317
  auth,
318
318
  db: database,
319
+ env: options?.env,
319
320
  log: noopLog,
320
321
  now: harnessNow,
321
322
  // eslint-disable-next-line @typescript-eslint/no-use-before-define -- lazy closure: `runInternal` is invoked only when a handler calls ctx.runQuery, after construction completes
@@ -327,6 +328,7 @@ const lunoraTest = (schema, options) => {
327
328
  const mutationContext = {
328
329
  auth,
329
330
  db: database,
331
+ env: options?.env,
330
332
  log: noopLog,
331
333
  now: harnessNow,
332
334
  // eslint-disable-next-line @typescript-eslint/no-use-before-define -- lazy closure: `runInternal` is invoked only when a handler calls ctx.runMutation, after construction completes
@@ -343,6 +345,7 @@ const lunoraTest = (schema, options) => {
343
345
  const actionContext = {
344
346
  auth,
345
347
  db: database,
348
+ env: options?.env,
346
349
  // Use the injected fetch when provided; fall back to the v1 stub otherwise.
347
350
  fetch: options?.fetch ?? stubProxy("fetch"),
348
351
  log: noopLog,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/testing",
3
- "version": "1.0.0-alpha.27",
3
+ "version": "1.0.0-alpha.28",
4
4
  "description": "Testing toolkit for Lunora: an in-memory harness for queries, mutations, and actions",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -46,10 +46,10 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/do": "1.0.0-alpha.22",
49
+ "@lunora/do": "1.0.0-alpha.23",
50
50
  "@lunora/errors": "1.0.0-alpha.1",
51
51
  "@lunora/mail": "1.0.0-alpha.6",
52
- "@lunora/server": "1.0.0-alpha.15"
52
+ "@lunora/server": "1.0.0-alpha.16"
53
53
  },
54
54
  "engines": {
55
55
  "node": "^22.15.0 || >=24.11.0"