@lunora/testing 1.0.0-alpha.4 → 1.0.0-alpha.6
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-
|
|
1
|
+
export { lunoraTest } from './packem_shared/lunoraTest-D8kUyDzR.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,6 +310,7 @@ 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),
|
|
314
316
|
storage: stubProxy("storage"),
|
|
@@ -318,6 +320,7 @@ const lunoraTest = (schema, options) => {
|
|
|
318
320
|
auth,
|
|
319
321
|
db: database,
|
|
320
322
|
log: noopLog,
|
|
323
|
+
now: harnessNow,
|
|
321
324
|
// 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
325
|
runMutation: (reference, args) => runInternal("mutation", reference, mutationContext, args),
|
|
323
326
|
// 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
|
|
@@ -334,6 +337,7 @@ const lunoraTest = (schema, options) => {
|
|
|
334
337
|
// Use the injected fetch when provided; fall back to the v1 stub otherwise.
|
|
335
338
|
fetch: options?.fetch ?? stubProxy("fetch"),
|
|
336
339
|
log: noopLog,
|
|
340
|
+
now: harnessNow,
|
|
337
341
|
// 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
342
|
runAction: (reference, args) => runInternal("action", reference, actionContext, args),
|
|
339
343
|
// 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
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunora/testing",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.6",
|
|
4
4
|
"description": "Testing toolkit for Lunora: an in-memory harness for queries, mutations, and actions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@lunora/do": "1.0.0-alpha.
|
|
49
|
+
"@lunora/do": "1.0.0-alpha.5",
|
|
50
50
|
"@lunora/mail": "1.0.0-alpha.1",
|
|
51
|
-
"@lunora/server": "1.0.0-alpha.
|
|
51
|
+
"@lunora/server": "1.0.0-alpha.3"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": "^22.15.0 || >=24.11.0"
|