@forinda/kickjs-testing 3.1.3 → 3.2.0
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 +70 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +52 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
|
|
2
2
|
import express from "express";
|
|
3
|
-
import { AppAdapter, AppModuleClass, Application, ApplicationOptions, Container, ModuleRoutes } from "@forinda/kickjs";
|
|
3
|
+
import { AppAdapter, AppModuleClass, Application, ApplicationOptions, Container, ContextDecorator, ExecutionContext, MetaValue, ModuleRoutes } from "@forinda/kickjs";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Bootstrap options forwarded verbatim to the underlying Application so
|
|
8
8
|
* test apps exercise the same HTTP pipeline shape as production.
|
|
9
9
|
*/
|
|
10
|
-
type BootstrapPassthroughOptions = Pick<ApplicationOptions, 'port' | 'apiPrefix' | 'defaultVersion' | 'middleware' | 'onError' | 'onNotFound' | 'plugins' | 'trustProxy' | 'jsonLimit' | 'security'>;
|
|
10
|
+
type BootstrapPassthroughOptions = Pick<ApplicationOptions, 'port' | 'apiPrefix' | 'defaultVersion' | 'middleware' | 'onError' | 'onNotFound' | 'plugins' | 'trustProxy' | 'jsonLimit' | 'security' | 'contributors' | 'contextStore'>;
|
|
11
11
|
/**
|
|
12
12
|
* Options for creating a test application.
|
|
13
13
|
* Disables helmet, cors, compression, and morgan by default.
|
|
@@ -63,6 +63,73 @@ declare function createTestModule(config: {
|
|
|
63
63
|
register: (container: Container) => void;
|
|
64
64
|
routes: () => ModuleRoutes | ModuleRoutes[] | null;
|
|
65
65
|
}): AppModuleClass;
|
|
66
|
+
/**
|
|
67
|
+
* Options for {@link runContributor}.
|
|
68
|
+
*/
|
|
69
|
+
interface RunContributorOptions {
|
|
70
|
+
/**
|
|
71
|
+
* Resolved deps passed to `resolve(ctx, deps)`. Skips the DI container
|
|
72
|
+
* entirely — bypass for unit tests that want to assert pure resolve()
|
|
73
|
+
* behaviour without standing up a container.
|
|
74
|
+
*
|
|
75
|
+
* Property names must match the spec's `deps` keys; values can be real
|
|
76
|
+
* service instances, mocks, or test doubles.
|
|
77
|
+
*/
|
|
78
|
+
deps?: Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Pre-populate the fake context's metadata Map. Useful for testing
|
|
81
|
+
* contributors with `dependsOn` without running the full pipeline:
|
|
82
|
+
* pre-populate the dependency keys, then assert that `resolve()` reads
|
|
83
|
+
* them and produces the expected output.
|
|
84
|
+
*/
|
|
85
|
+
initial?: Record<string, unknown>;
|
|
86
|
+
/** Override the fake context's `requestId` (default: `'test-req'`). */
|
|
87
|
+
requestId?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Result of {@link runContributor}.
|
|
91
|
+
*/
|
|
92
|
+
interface RunContributorResult<K extends string> {
|
|
93
|
+
/** Value returned by the contributor's `resolve()` call. */
|
|
94
|
+
value: MetaValue<K>;
|
|
95
|
+
/** The fake `ExecutionContext` used during the run. */
|
|
96
|
+
ctx: ExecutionContext;
|
|
97
|
+
/**
|
|
98
|
+
* Final state of the fake context's metadata Map after `resolve()`.
|
|
99
|
+
* Includes any `ctx.set(...)` calls the resolver made plus the final
|
|
100
|
+
* resolved value under the contributor's own key.
|
|
101
|
+
*/
|
|
102
|
+
meta: Map<string, unknown>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Run a single context contributor in isolation against a fake
|
|
106
|
+
* {@link ExecutionContext}. Skips the container, the topo-sort, and the
|
|
107
|
+
* §20.9 error matrix — calls `decorator.registration.resolve(ctx, deps)`
|
|
108
|
+
* directly so unit tests can assert pure resolve behaviour.
|
|
109
|
+
*
|
|
110
|
+
* Errors thrown by `resolve()` propagate so tests can `expect(...).rejects`
|
|
111
|
+
* or `await expect(...).rejects.toThrow()` against them. To exercise the
|
|
112
|
+
* full error matrix (optional skip, onError replacement, etc.), build a
|
|
113
|
+
* one-element pipeline with `buildPipeline()` and use `runContributors()`
|
|
114
|
+
* directly.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```ts
|
|
118
|
+
* const LoadProject = defineContextDecorator({
|
|
119
|
+
* key: 'project',
|
|
120
|
+
* dependsOn: ['tenant'],
|
|
121
|
+
* deps: { repo: ProjectRepo },
|
|
122
|
+
* resolve: (ctx, { repo }) => repo.findByTenant(ctx.get('tenant')!.id),
|
|
123
|
+
* })
|
|
124
|
+
*
|
|
125
|
+
* const { value } = await runContributor(LoadProject, {
|
|
126
|
+
* initial: { tenant: { id: 't-1' } },
|
|
127
|
+
* deps: { repo: new InMemoryProjectRepo([{ id: 'p-1', tenantId: 't-1' }]) },
|
|
128
|
+
* })
|
|
129
|
+
* expect(value).toEqual({ id: 'p-1', tenantId: 't-1' })
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
declare function runContributor<K extends string, D extends Record<string, any> = Record<string, never>>(decorator: ContextDecorator<K, D, ExecutionContext>, options?: RunContributorOptions): Promise<RunContributorResult<K>>;
|
|
66
133
|
//#endregion
|
|
67
|
-
export { CreateTestAppOptions, createTestApp, createTestModule };
|
|
134
|
+
export { CreateTestAppOptions, RunContributorOptions, RunContributorResult, createTestApp, createTestModule, runContributor };
|
|
68
135
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;AAYwB;;KAMnB,2BAAA,GAA8B,IAAA,CACjC,kBAAA;;;AAmBF;;UAAiB,oBAAA,SAA6B,2BAAA;EAC5C,OAAA,EAAS,cAAA;EAEE;EAAX,QAAA,GAAW,UAAA;EAHiC;EAK5C,SAAA,GAAY,MAAA;EAL2D;;;;;EAWvE,QAAA;AAAA;;;;;AAiBF;;;;;;;;;;iBAAsB,aAAA,CAAc,OAAA,EAAS,oBAAA,GAAuB,OAAA;EAClE,GAAA,EAAK,WAAA;EACL,UAAA,EAAY,OAAA,CAAQ,OAAA;EACpB,SAAA,EAAW,SAAA;AAAA;;;;;;;;AA4Eb;;;;;;;;iBAAgB,gBAAA,CAAiB,MAAA;EAC/B,QAAA,GAAW,SAAA,EAAW,SAAA;EACtB,MAAA,QAAc,YAAA,GAAe,YAAA;AAAA,IAC3B,cAAA;;;;UAiBa,qBAAA;EAjBb;;;AAiBJ;;;;;EASE,IAAA,GAAO,MAAA;EAQP;;;;;AASF;EATE,OAAA,GAAU,MAAA;EASyB;EANnC,SAAA;AAAA;;;;UAMe,oBAAA;EAAqB;EAEpC,KAAA,EAAO,SAAA,CAAU,CAAA;EAAV;EAEP,GAAA,EAAK,gBAAA;EAAL;;;;;EAMA,IAAA,EAAM,GAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA+Bc,cAAA,6BAEV,MAAA,gBAAsB,MAAA,gBAAA,CAEhC,SAAA,EAAW,gBAAA,CAAiB,CAAA,EAAG,CAAA,EAAG,gBAAA,GAClC,OAAA,GAAS,qBAAA,GACR,OAAA,CAAQ,oBAAA,CAAqB,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @forinda/kickjs-testing v3.
|
|
2
|
+
* @forinda/kickjs-testing v3.2.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Felix Orinda
|
|
5
5
|
*
|
|
@@ -44,7 +44,9 @@ async function createTestApp(options) {
|
|
|
44
44
|
plugins: options.plugins,
|
|
45
45
|
trustProxy: options.trustProxy,
|
|
46
46
|
jsonLimit: options.jsonLimit,
|
|
47
|
-
security: options.security
|
|
47
|
+
security: options.security,
|
|
48
|
+
contributors: options.contributors,
|
|
49
|
+
contextStore: options.contextStore
|
|
48
50
|
});
|
|
49
51
|
await Promise.resolve(app.setup());
|
|
50
52
|
if (options.isolated) {
|
|
@@ -84,7 +86,54 @@ function createTestModule(config) {
|
|
|
84
86
|
}
|
|
85
87
|
return TestModule;
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Run a single context contributor in isolation against a fake
|
|
91
|
+
* {@link ExecutionContext}. Skips the container, the topo-sort, and the
|
|
92
|
+
* §20.9 error matrix — calls `decorator.registration.resolve(ctx, deps)`
|
|
93
|
+
* directly so unit tests can assert pure resolve behaviour.
|
|
94
|
+
*
|
|
95
|
+
* Errors thrown by `resolve()` propagate so tests can `expect(...).rejects`
|
|
96
|
+
* or `await expect(...).rejects.toThrow()` against them. To exercise the
|
|
97
|
+
* full error matrix (optional skip, onError replacement, etc.), build a
|
|
98
|
+
* one-element pipeline with `buildPipeline()` and use `runContributors()`
|
|
99
|
+
* directly.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* const LoadProject = defineContextDecorator({
|
|
104
|
+
* key: 'project',
|
|
105
|
+
* dependsOn: ['tenant'],
|
|
106
|
+
* deps: { repo: ProjectRepo },
|
|
107
|
+
* resolve: (ctx, { repo }) => repo.findByTenant(ctx.get('tenant')!.id),
|
|
108
|
+
* })
|
|
109
|
+
*
|
|
110
|
+
* const { value } = await runContributor(LoadProject, {
|
|
111
|
+
* initial: { tenant: { id: 't-1' } },
|
|
112
|
+
* deps: { repo: new InMemoryProjectRepo([{ id: 'p-1', tenantId: 't-1' }]) },
|
|
113
|
+
* })
|
|
114
|
+
* expect(value).toEqual({ id: 'p-1', tenantId: 't-1' })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
async function runContributor(decorator, options = {}) {
|
|
118
|
+
const meta = new Map(Object.entries(options.initial ?? {}));
|
|
119
|
+
const ctx = {
|
|
120
|
+
get(key) {
|
|
121
|
+
return meta.get(key);
|
|
122
|
+
},
|
|
123
|
+
set(key, value) {
|
|
124
|
+
meta.set(key, value);
|
|
125
|
+
},
|
|
126
|
+
requestId: options.requestId ?? "test-req"
|
|
127
|
+
};
|
|
128
|
+
const value = await decorator.registration.resolve(ctx, options.deps ?? {});
|
|
129
|
+
meta.set(decorator.registration.key, value);
|
|
130
|
+
return {
|
|
131
|
+
value,
|
|
132
|
+
ctx,
|
|
133
|
+
meta
|
|
134
|
+
};
|
|
135
|
+
}
|
|
87
136
|
//#endregion
|
|
88
|
-
export { createTestApp, createTestModule };
|
|
137
|
+
export { createTestApp, createTestModule, runContributor };
|
|
89
138
|
|
|
90
139
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import express from 'express'\nimport {\n Application,\n Container,\n type AppAdapter,\n type AppModule,\n type AppModuleClass,\n type ApplicationOptions,\n type ModuleRoutes,\n} from '@forinda/kickjs'\n\n/**\n * Bootstrap options forwarded verbatim to the underlying Application so\n * test apps exercise the same HTTP pipeline shape as production.\n */\ntype BootstrapPassthroughOptions = Pick<\n ApplicationOptions,\n | 'port'\n | 'apiPrefix'\n | 'defaultVersion'\n | 'middleware'\n | 'onError'\n | 'onNotFound'\n | 'plugins'\n | 'trustProxy'\n | 'jsonLimit'\n | 'security'\n>\n\n/**\n * Options for creating a test application.\n * Disables helmet, cors, compression, and morgan by default.\n */\nexport interface CreateTestAppOptions extends BootstrapPassthroughOptions {\n modules: AppModuleClass[]\n /** Adapters to attach (auth, queue, devtools, etc.) */\n adapters?: AppAdapter[]\n /** DI overrides applied after module registration. Supports both string and symbol keys. */\n overrides?: Record<symbol | string, any>\n /**\n * Use an isolated container instead of the global singleton.\n * Prevents concurrent tests from interfering with each other's DI state.\n * When true, Container.create() is used instead of Container.reset() + getInstance().\n */\n isolated?: boolean\n}\n\n/**\n * Create an Application instance configured for testing.\n * Resets the DI container, registers modules, applies overrides,\n * and returns both the Application and its Express app.\n *\n * @example\n * ```ts\n * const { expressApp, container } = await createTestApp({\n * modules: [UserModule],\n * overrides: { [USER_REPO]: new InMemoryUserRepo() },\n * })\n * const res = await request(expressApp).get('/api/v1/users')\n * ```\n */\nexport async function createTestApp(options: CreateTestAppOptions): Promise<{\n app: Application\n expressApp: express.Express\n container: Container\n}> {\n let container: Container\n if (options.isolated) {\n // Isolated container — safe for concurrent tests\n container = Container.create()\n } else {\n // Global singleton — reset for serial test isolation (default)\n Container.reset()\n container = Container.getInstance()\n }\n\n const app = new Application({\n modules: options.modules,\n adapters: options.adapters,\n port: options.port,\n apiPrefix: options.apiPrefix,\n defaultVersion: options.defaultVersion,\n // Use provided middleware, or default to JSON body parsing only\n middleware: options.middleware ?? [express.json()],\n onError: options.onError,\n onNotFound: options.onNotFound,\n plugins: options.plugins,\n trustProxy: options.trustProxy,\n jsonLimit: options.jsonLimit,\n security: options.security,\n })\n\n // Run setup — mounts routes, registers modules, initializes adapters.\n // Awaited to support future async adapter hooks.\n await Promise.resolve(app.setup())\n\n // When using an isolated container, Application.setup() registers modules\n // on the global singleton (Container.getInstance()). Re-register them on\n // the isolated container so that bindings are available there too.\n if (options.isolated) {\n for (const ModuleClass of options.modules) {\n const mod = new ModuleClass()\n // register() is optional — see AppModule docs\n mod.register?.(container)\n }\n container.bootstrap()\n }\n\n // Apply DI overrides AFTER setup so they take precedence over\n // bindings registered by modules during register().\n if (options.overrides) {\n for (const token of Reflect.ownKeys(options.overrides)) {\n container.registerInstance(token, options.overrides[token as any])\n }\n }\n\n return {\n app,\n expressApp: app.getExpressApp(),\n container,\n }\n}\n\n/**\n * Build a quick TestModule that explicitly registers dependencies.\n * Useful for integration tests that need to control the DI graph.\n *\n * @example\n * ```ts\n * const TestModule = createTestModule({\n * register: (c) => {\n * c.registerFactory(USER_REPO, () => new InMemoryUserRepo())\n * c.register(UserController)\n * },\n * routes: () => buildRoutes(UserController, '/users'),\n * })\n * ```\n */\nexport function createTestModule(config: {\n register: (container: Container) => void\n routes: () => ModuleRoutes | ModuleRoutes[] | null\n}): AppModuleClass {\n class TestModule implements AppModule {\n register(container: Container) {\n config.register(container)\n }\n routes() {\n return config.routes()\n }\n }\n return TestModule\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import express from 'express'\nimport {\n Application,\n Container,\n type AppAdapter,\n type AppModule,\n type AppModuleClass,\n type ApplicationOptions,\n type ContextDecorator,\n type ExecutionContext,\n type MetaValue,\n type ModuleRoutes,\n} from '@forinda/kickjs'\n\n/**\n * Bootstrap options forwarded verbatim to the underlying Application so\n * test apps exercise the same HTTP pipeline shape as production.\n */\ntype BootstrapPassthroughOptions = Pick<\n ApplicationOptions,\n | 'port'\n | 'apiPrefix'\n | 'defaultVersion'\n | 'middleware'\n | 'onError'\n | 'onNotFound'\n | 'plugins'\n | 'trustProxy'\n | 'jsonLimit'\n | 'security'\n | 'contributors'\n | 'contextStore'\n>\n\n/**\n * Options for creating a test application.\n * Disables helmet, cors, compression, and morgan by default.\n */\nexport interface CreateTestAppOptions extends BootstrapPassthroughOptions {\n modules: AppModuleClass[]\n /** Adapters to attach (auth, queue, devtools, etc.) */\n adapters?: AppAdapter[]\n /** DI overrides applied after module registration. Supports both string and symbol keys. */\n overrides?: Record<symbol | string, any>\n /**\n * Use an isolated container instead of the global singleton.\n * Prevents concurrent tests from interfering with each other's DI state.\n * When true, Container.create() is used instead of Container.reset() + getInstance().\n */\n isolated?: boolean\n}\n\n/**\n * Create an Application instance configured for testing.\n * Resets the DI container, registers modules, applies overrides,\n * and returns both the Application and its Express app.\n *\n * @example\n * ```ts\n * const { expressApp, container } = await createTestApp({\n * modules: [UserModule],\n * overrides: { [USER_REPO]: new InMemoryUserRepo() },\n * })\n * const res = await request(expressApp).get('/api/v1/users')\n * ```\n */\nexport async function createTestApp(options: CreateTestAppOptions): Promise<{\n app: Application\n expressApp: express.Express\n container: Container\n}> {\n let container: Container\n if (options.isolated) {\n // Isolated container — safe for concurrent tests\n container = Container.create()\n } else {\n // Global singleton — reset for serial test isolation (default)\n Container.reset()\n container = Container.getInstance()\n }\n\n const app = new Application({\n modules: options.modules,\n adapters: options.adapters,\n port: options.port,\n apiPrefix: options.apiPrefix,\n defaultVersion: options.defaultVersion,\n // Use provided middleware, or default to JSON body parsing only\n middleware: options.middleware ?? [express.json()],\n onError: options.onError,\n onNotFound: options.onNotFound,\n plugins: options.plugins,\n trustProxy: options.trustProxy,\n jsonLimit: options.jsonLimit,\n security: options.security,\n contributors: options.contributors,\n contextStore: options.contextStore,\n })\n\n // Run setup — mounts routes, registers modules, initializes adapters.\n // Awaited to support future async adapter hooks.\n await Promise.resolve(app.setup())\n\n // When using an isolated container, Application.setup() registers modules\n // on the global singleton (Container.getInstance()). Re-register them on\n // the isolated container so that bindings are available there too.\n if (options.isolated) {\n for (const ModuleClass of options.modules) {\n const mod = new ModuleClass()\n // register() is optional — see AppModule docs\n mod.register?.(container)\n }\n container.bootstrap()\n }\n\n // Apply DI overrides AFTER setup so they take precedence over\n // bindings registered by modules during register().\n if (options.overrides) {\n for (const token of Reflect.ownKeys(options.overrides)) {\n container.registerInstance(token, options.overrides[token as any])\n }\n }\n\n return {\n app,\n expressApp: app.getExpressApp(),\n container,\n }\n}\n\n/**\n * Build a quick TestModule that explicitly registers dependencies.\n * Useful for integration tests that need to control the DI graph.\n *\n * @example\n * ```ts\n * const TestModule = createTestModule({\n * register: (c) => {\n * c.registerFactory(USER_REPO, () => new InMemoryUserRepo())\n * c.register(UserController)\n * },\n * routes: () => buildRoutes(UserController, '/users'),\n * })\n * ```\n */\nexport function createTestModule(config: {\n register: (container: Container) => void\n routes: () => ModuleRoutes | ModuleRoutes[] | null\n}): AppModuleClass {\n class TestModule implements AppModule {\n register(container: Container) {\n config.register(container)\n }\n routes() {\n return config.routes()\n }\n }\n return TestModule\n}\n\n// ── Context Contributor unit-test helper (#107) ─────────────────────────\n\n/**\n * Options for {@link runContributor}.\n */\nexport interface RunContributorOptions {\n /**\n * Resolved deps passed to `resolve(ctx, deps)`. Skips the DI container\n * entirely — bypass for unit tests that want to assert pure resolve()\n * behaviour without standing up a container.\n *\n * Property names must match the spec's `deps` keys; values can be real\n * service instances, mocks, or test doubles.\n */\n deps?: Record<string, unknown>\n\n /**\n * Pre-populate the fake context's metadata Map. Useful for testing\n * contributors with `dependsOn` without running the full pipeline:\n * pre-populate the dependency keys, then assert that `resolve()` reads\n * them and produces the expected output.\n */\n initial?: Record<string, unknown>\n\n /** Override the fake context's `requestId` (default: `'test-req'`). */\n requestId?: string\n}\n\n/**\n * Result of {@link runContributor}.\n */\nexport interface RunContributorResult<K extends string> {\n /** Value returned by the contributor's `resolve()` call. */\n value: MetaValue<K>\n /** The fake `ExecutionContext` used during the run. */\n ctx: ExecutionContext\n /**\n * Final state of the fake context's metadata Map after `resolve()`.\n * Includes any `ctx.set(...)` calls the resolver made plus the final\n * resolved value under the contributor's own key.\n */\n meta: Map<string, unknown>\n}\n\n/**\n * Run a single context contributor in isolation against a fake\n * {@link ExecutionContext}. Skips the container, the topo-sort, and the\n * §20.9 error matrix — calls `decorator.registration.resolve(ctx, deps)`\n * directly so unit tests can assert pure resolve behaviour.\n *\n * Errors thrown by `resolve()` propagate so tests can `expect(...).rejects`\n * or `await expect(...).rejects.toThrow()` against them. To exercise the\n * full error matrix (optional skip, onError replacement, etc.), build a\n * one-element pipeline with `buildPipeline()` and use `runContributors()`\n * directly.\n *\n * @example\n * ```ts\n * const LoadProject = defineContextDecorator({\n * key: 'project',\n * dependsOn: ['tenant'],\n * deps: { repo: ProjectRepo },\n * resolve: (ctx, { repo }) => repo.findByTenant(ctx.get('tenant')!.id),\n * })\n *\n * const { value } = await runContributor(LoadProject, {\n * initial: { tenant: { id: 't-1' } },\n * deps: { repo: new InMemoryProjectRepo([{ id: 'p-1', tenantId: 't-1' }]) },\n * })\n * expect(value).toEqual({ id: 'p-1', tenantId: 't-1' })\n * ```\n */\nexport async function runContributor<\n K extends string,\n D extends Record<string, any> = Record<string, never>,\n>(\n decorator: ContextDecorator<K, D, ExecutionContext>,\n options: RunContributorOptions = {},\n): Promise<RunContributorResult<K>> {\n const meta = new Map<string, unknown>(Object.entries(options.initial ?? {}))\n const ctx: ExecutionContext = {\n get(key) {\n return meta.get(key) as never\n },\n set(key, value) {\n meta.set(key, value)\n },\n requestId: options.requestId ?? 'test-req',\n }\n\n const value = await decorator.registration.resolve(ctx, (options.deps ?? {}) as never)\n meta.set(decorator.registration.key, value)\n\n return { value: value as MetaValue<K>, ctx, meta }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,eAAsB,cAAc,SAIjC;CACD,IAAI;AACJ,KAAI,QAAQ,SAEV,aAAY,UAAU,QAAQ;MACzB;AAEL,YAAU,OAAO;AACjB,cAAY,UAAU,aAAa;;CAGrC,MAAM,MAAM,IAAI,YAAY;EAC1B,SAAS,QAAQ;EACjB,UAAU,QAAQ;EAClB,MAAM,QAAQ;EACd,WAAW,QAAQ;EACnB,gBAAgB,QAAQ;EAExB,YAAY,QAAQ,cAAc,CAAC,QAAQ,MAAM,CAAC;EAClD,SAAS,QAAQ;EACjB,YAAY,QAAQ;EACpB,SAAS,QAAQ;EACjB,YAAY,QAAQ;EACpB,WAAW,QAAQ;EACnB,UAAU,QAAQ;EAClB,cAAc,QAAQ;EACtB,cAAc,QAAQ;EACvB,CAAC;AAIF,OAAM,QAAQ,QAAQ,IAAI,OAAO,CAAC;AAKlC,KAAI,QAAQ,UAAU;AACpB,OAAK,MAAM,eAAe,QAAQ,QACpB,KAAI,aAAa,CAEzB,WAAW,UAAU;AAE3B,YAAU,WAAW;;AAKvB,KAAI,QAAQ,UACV,MAAK,MAAM,SAAS,QAAQ,QAAQ,QAAQ,UAAU,CACpD,WAAU,iBAAiB,OAAO,QAAQ,UAAU,OAAc;AAItE,QAAO;EACL;EACA,YAAY,IAAI,eAAe;EAC/B;EACD;;;;;;;;;;;;;;;;;AAkBH,SAAgB,iBAAiB,QAGd;CACjB,MAAM,WAAgC;EACpC,SAAS,WAAsB;AAC7B,UAAO,SAAS,UAAU;;EAE5B,SAAS;AACP,UAAO,OAAO,QAAQ;;;AAG1B,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2ET,eAAsB,eAIpB,WACA,UAAiC,EAAE,EACD;CAClC,MAAM,OAAO,IAAI,IAAqB,OAAO,QAAQ,QAAQ,WAAW,EAAE,CAAC,CAAC;CAC5E,MAAM,MAAwB;EAC5B,IAAI,KAAK;AACP,UAAO,KAAK,IAAI,IAAI;;EAEtB,IAAI,KAAK,OAAO;AACd,QAAK,IAAI,KAAK,MAAM;;EAEtB,WAAW,QAAQ,aAAa;EACjC;CAED,MAAM,QAAQ,MAAM,UAAU,aAAa,QAAQ,KAAM,QAAQ,QAAQ,EAAE,CAAW;AACtF,MAAK,IAAI,UAAU,aAAa,KAAK,MAAM;AAE3C,QAAO;EAAS;EAAuB;EAAK;EAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forinda/kickjs-testing",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Test utilities, TestModule builder, and helpers for KickJS applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kickjs",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"supertest": "^7.2.2",
|
|
85
85
|
"typescript": "^5.9.2",
|
|
86
86
|
"vitest": "^4.1.2",
|
|
87
|
-
"@forinda/kickjs": "3.
|
|
87
|
+
"@forinda/kickjs": "3.2.0"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public"
|