@lunora/testing 1.0.0-alpha.2 → 1.0.0-alpha.20

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
@@ -171,6 +171,16 @@ interface LunoraTestOptions {
171
171
  * ```
172
172
  */
173
173
  functions?: FunctionRegistry;
174
+ /**
175
+ * Fixed value for `ctx.now` (epoch ms) in every context. Production captures
176
+ * `Date.now()` once per execution; in tests a fixed `now` makes time-dependent
177
+ * handlers deterministic. Defaults to the wall clock at harness creation.
178
+ * @example
179
+ * ```ts
180
+ * const t = lunoraTest(schema, { now: 1_700_000_000_000 });
181
+ * ```
182
+ */
183
+ now?: number;
174
184
  }
175
185
  /**
176
186
  * The in-memory test harness returned by {@link lunoraTest}. Mirrors the first
package/dist/index.d.ts CHANGED
@@ -171,6 +171,16 @@ interface LunoraTestOptions {
171
171
  * ```
172
172
  */
173
173
  functions?: FunctionRegistry;
174
+ /**
175
+ * Fixed value for `ctx.now` (epoch ms) in every context. Production captures
176
+ * `Date.now()` once per execution; in tests a fixed `now` makes time-dependent
177
+ * handlers deterministic. Defaults to the wall clock at harness creation.
178
+ * @example
179
+ * ```ts
180
+ * const t = lunoraTest(schema, { now: 1_700_000_000_000 });
181
+ * ```
182
+ */
183
+ now?: number;
174
184
  }
175
185
  /**
176
186
  * The in-memory test harness returned by {@link lunoraTest}. Mirrors the first
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { lunoraTest } from './packem_shared/lunoraTest-BUg4Ebv8.mjs';
1
+ export { lunoraTest } from './packem_shared/lunoraTest-Dm9lhBEx.mjs';
2
2
  export { extractLink, listCapturedMail, waitForMail } from '@lunora/mail/testing';
@@ -298,6 +298,7 @@ const lunoraTest = (schema, options) => {
298
298
  },
299
299
  () => functionRegistryMap
300
300
  );
301
+ const harnessNow = options?.now ?? Date.now();
301
302
  const makeHarness = (identity) => {
302
303
  const auth = {
303
304
  // eslint-disable-next-line unicorn/no-null -- AuthState.getIdentity's anonymous sentinel is `null` (mirrors a decoded JWT being absent)
@@ -309,8 +310,10 @@ const lunoraTest = (schema, options) => {
309
310
  auth,
310
311
  db: database,
311
312
  log: noopLog,
313
+ now: harnessNow,
312
314
  // 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
313
315
  runQuery: (reference, args) => runInternal("query", reference, queryContext, args),
316
+ secrets: stubProxy("secrets"),
314
317
  storage: stubProxy("storage"),
315
318
  vectors: stubProxy("vectors")
316
319
  };
@@ -318,11 +321,13 @@ const lunoraTest = (schema, options) => {
318
321
  auth,
319
322
  db: database,
320
323
  log: noopLog,
324
+ now: harnessNow,
321
325
  // 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
322
326
  runMutation: (reference, args) => runInternal("mutation", reference, mutationContext, args),
323
327
  // 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
324
328
  runQuery: (reference, args) => runInternal("query", reference, queryContext, args),
325
329
  scheduler: fakeScheduler,
330
+ secrets: stubProxy("secrets"),
326
331
  storage: stubProxy("storage"),
327
332
  vectors: stubProxy("vectors"),
328
333
  workflows: stubProxy("workflows")
@@ -334,6 +339,7 @@ const lunoraTest = (schema, options) => {
334
339
  // Use the injected fetch when provided; fall back to the v1 stub otherwise.
335
340
  fetch: options?.fetch ?? stubProxy("fetch"),
336
341
  log: noopLog,
342
+ now: harnessNow,
337
343
  // eslint-disable-next-line @typescript-eslint/no-use-before-define -- lazy closure: `runInternal` is invoked only when a handler calls ctx.runAction, after construction completes
338
344
  runAction: (reference, args) => runInternal("action", reference, actionContext, args),
339
345
  // 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
@@ -341,6 +347,7 @@ const lunoraTest = (schema, options) => {
341
347
  // 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
342
348
  runQuery: (reference, args) => runInternal("query", reference, queryContext, args),
343
349
  scheduler: fakeScheduler,
350
+ secrets: stubProxy("secrets"),
344
351
  storage: stubProxy("storage"),
345
352
  vectors: stubProxy("vectors"),
346
353
  workflows: stubProxy("workflows")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/testing",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.20",
4
4
  "description": "Testing toolkit for Lunora: an in-memory harness for queries, mutations, and actions",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -25,7 +25,7 @@
25
25
  "directory": "packages/testing"
26
26
  },
27
27
  "files": [
28
- "dist",
28
+ "./dist",
29
29
  "README.md",
30
30
  "LICENSE.md",
31
31
  "__assets__"
@@ -46,9 +46,9 @@
46
46
  "access": "public"
47
47
  },
48
48
  "dependencies": {
49
- "@lunora/do": "1.0.0-alpha.2",
50
- "@lunora/mail": "1.0.0-alpha.1",
51
- "@lunora/server": "1.0.0-alpha.1"
49
+ "@lunora/do": "1.0.0-alpha.16",
50
+ "@lunora/mail": "1.0.0-alpha.4",
51
+ "@lunora/server": "1.0.0-alpha.11"
52
52
  },
53
53
  "engines": {
54
54
  "node": "^22.15.0 || >=24.11.0"