@noego/testing 0.2.0 → 0.5.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.cjs CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var index_exports = {};
22
22
  __export(index_exports, {
23
+ AmbiguousNameKeyError: () => AmbiguousNameKeyError,
23
24
  CallScriptExhaustedError: () => CallScriptExhaustedError,
24
25
  ENV_REGISTRY: () => ENV_REGISTRY,
25
26
  ExpectationOverflowError: () => ExpectationOverflowError,
@@ -29,9 +30,11 @@ __export(index_exports, {
29
30
  NonObjectMethodTargetError: () => NonObjectMethodTargetError,
30
31
  TestIocBuilder: () => TestIocBuilder,
31
32
  TestingError: () => TestingError,
33
+ TokenIdentitySplitError: () => TokenIdentitySplitError,
32
34
  UnknownTokenKeyError: () => UnknownTokenKeyError,
33
35
  UnwatchedInspectionError: () => UnwatchedInspectionError,
34
36
  VerificationError: () => VerificationError,
37
+ installSeams: () => installSeams,
35
38
  test: () => test,
36
39
  testIoc: () => testIoc
37
40
  });
@@ -107,6 +110,22 @@ var UnknownTokenKeyError = class extends TestingError {
107
110
  };
108
111
  var InvalidDescriptorError = class extends TestingError {
109
112
  };
113
+ var AmbiguousNameKeyError = class extends TestingError {
114
+ constructor(name, space) {
115
+ super(
116
+ `.${space}() key "${name}" is ambiguous: multiple distinct tokens share that display name. Use the canonical tuple form with the exact token: .${space}([[TheToken, ...]]).`
117
+ );
118
+ this.name = "AmbiguousNameKeyError";
119
+ }
120
+ };
121
+ var TokenIdentitySplitError = class extends TestingError {
122
+ constructor(names) {
123
+ super(
124
+ `token identity split: .methods() entr${names.length === 1 ? "y" : "ies"} for ${names.map((name) => `"${name}"`).join(", ")} never matched a constructed instance, but a DIFFERENT class with the same name was constructed. Two module registries have loaded the same class file (test-file import vs harness graph import) \u2014 the configured behavior did not apply. Route the harness's imports through your registry (e.g. testApp .importer((p) => import(p))) or pass the exact token the graph uses.`
125
+ );
126
+ this.name = "TokenIdentitySplitError";
127
+ }
128
+ };
110
129
 
111
130
  // src/descriptors.ts
112
131
  var DESCRIPTOR = /* @__PURE__ */ Symbol.for("noego:testing:descriptor");
@@ -227,6 +246,10 @@ var WatchRegistry = class {
227
246
  states = /* @__PURE__ */ new Map();
228
247
  nameIndex = /* @__PURE__ */ new Map();
229
248
  entries = [];
249
+ /** Class-token entries that identity-matched at least one construction. */
250
+ matchedEntryKeys = /* @__PURE__ */ new Set();
251
+ /** Constructed class tokens that matched NO entry, by display name. */
252
+ unmatchedConstructedByName = /* @__PURE__ */ new Map();
230
253
  addEntry(entry) {
231
254
  this.entries.push(entry);
232
255
  const byMethod = /* @__PURE__ */ new Map();
@@ -246,9 +269,15 @@ var WatchRegistry = class {
246
269
  /** Entries applying to a resolving token (exact identity or name match). */
247
270
  matchEntries(token) {
248
271
  const name = typeof token === "function" ? token.name : typeof token === "string" ? token : void 0;
249
- return this.entries.filter(
272
+ const matched = this.entries.filter(
250
273
  (entry) => entry.key === token || entry.byName && name !== void 0 && entry.key === name
251
274
  );
275
+ if (matched.length) {
276
+ for (const entry of matched) this.matchedEntryKeys.add(entry.key);
277
+ } else if (typeof token === "function" && name) {
278
+ this.unmatchedConstructedByName.set(name, token);
279
+ }
280
+ return matched;
252
281
  }
253
282
  state(entryKey, method) {
254
283
  return this.states.get(entryKey)?.get(method);
@@ -264,8 +293,34 @@ var WatchRegistry = class {
264
293
  }
265
294
  throw new UnwatchedInspectionError(label, method);
266
295
  }
296
+ /**
297
+ * Class-token entries that never identity-matched a construction while a
298
+ * DIFFERENT class with the same display name did construct. This is the
299
+ * split-module-registry signature (a test-file class object vs the graph's
300
+ * own load of the same file) — or two genuinely distinct same-named tokens
301
+ * where the configured one never resolved. Either way the configured
302
+ * behavior silently did not apply, which must be loud.
303
+ */
304
+ identitySplits() {
305
+ const splits = [];
306
+ for (const entry of this.entries) {
307
+ if (entry.byName || typeof entry.key !== "function") continue;
308
+ if (this.matchedEntryKeys.has(entry.key)) continue;
309
+ const name = entry.key.name;
310
+ if (!name) continue;
311
+ const constructed = this.unmatchedConstructedByName.get(name);
312
+ if (constructed !== void 0 && constructed !== entry.key) {
313
+ splits.push({ name, entryToken: entry.key });
314
+ }
315
+ }
316
+ return splits;
317
+ }
267
318
  /** Repeatable snapshot check of all exact expectations. */
268
319
  verify() {
320
+ const splits = this.identitySplits();
321
+ if (splits.length) {
322
+ throw new TokenIdentitySplitError(splits.map((split) => split.name));
323
+ }
269
324
  const failures = [];
270
325
  for (const byMethod of this.states.values()) {
271
326
  for (const state of byMethod.values()) {
@@ -414,7 +469,16 @@ function buildMethodWrapper(target, method, descriptor, state) {
414
469
  // src/builder.ts
415
470
  var COMPONENT_OPTIONS_KEY = /* @__PURE__ */ Symbol.for("ioc:component:options");
416
471
  function* configEntries(config) {
417
- if (config instanceof Map) {
472
+ if (Array.isArray(config)) {
473
+ for (const entry of config) {
474
+ if (!Array.isArray(entry) || entry.length !== 2) {
475
+ throw new InvalidDescriptorError(
476
+ "canonical composition entries are [token, value] tuples, e.g. .classes([[Token, Impl]])"
477
+ );
478
+ }
479
+ yield [entry[0], false, entry[1]];
480
+ }
481
+ } else if (config instanceof Map) {
418
482
  for (const [key, value] of config) yield [key, false, value];
419
483
  } else {
420
484
  for (const key of [...Object.getOwnPropertyNames(config), ...Object.getOwnPropertySymbols(config)]) {
@@ -510,23 +574,40 @@ var TestIocBuilder = class _TestIocBuilder {
510
574
  }
511
575
  return this.derive(writes);
512
576
  }
513
- /** Materialize a fresh, isolated real-IoC environment. Non-consuming. */
514
- async build() {
577
+ /**
578
+ * Materialize a fresh, isolated real-IoC environment. Non-consuming.
579
+ *
580
+ * `prepare` runs on the fresh root BEFORE this builder's registrations and
581
+ * the method-control decorator are applied: the place for an application's
582
+ * production composition, so every declared seam shadows what production
583
+ * registered for the same token, and instances constructed later are
584
+ * decorated. Instances `prepare` constructs itself are not decorated.
585
+ */
586
+ async build(options = {}) {
515
587
  const root = (0, import_ioc.createContainer)();
516
588
  if (typeof root.setInstanceDecorator !== "function") {
517
589
  throw new MissingIocSeamError();
518
590
  }
591
+ await options.prepare?.(root);
519
592
  const knownByName = /* @__PURE__ */ new Map();
593
+ const ambiguousNames = /* @__PURE__ */ new Set();
520
594
  const knownLifetimes = /* @__PURE__ */ new Map();
521
595
  const note = (token, loadAs) => {
522
- if (typeof token === "function" && token.name) knownByName.set(token.name, token);
523
- else if (typeof token === "string") knownByName.set(token, token);
596
+ const name = typeof token === "function" && token.name ? token.name : typeof token === "string" ? token : null;
597
+ if (name !== null) {
598
+ const existing = knownByName.get(name);
599
+ if (existing !== void 0 && existing !== token) ambiguousNames.add(name);
600
+ knownByName.set(name, token);
601
+ }
524
602
  if (loadAs !== void 0) knownLifetimes.set(token, loadAs);
525
603
  };
526
604
  const effective = /* @__PURE__ */ new Map();
527
605
  const methodWrites = [];
528
606
  const resolveKey = (key, byName, space) => {
529
607
  if (!byName) return key;
608
+ if (ambiguousNames.has(key)) {
609
+ throw new AmbiguousNameKeyError(key, space);
610
+ }
530
611
  const known = knownByName.get(key);
531
612
  if (known !== void 0) return known;
532
613
  if (space === "values" || space === "functions") return key;
@@ -571,8 +652,13 @@ var TestIocBuilder = class _TestIocBuilder {
571
652
  space: "class",
572
653
  token,
573
654
  implementation: write.implementation,
574
- // preserve configured lifetime unless the replacement declares its own scope
575
- loadAs: componentScope(write.implementation) ?? knownLifetimes.get(token)
655
+ // Lifetime priority: the replacement's own @Component scope, then
656
+ // the lifetime the composition already knows for the token, then
657
+ // the TOKEN class's declared @Component scope — a plain stub
658
+ // class replacing a Singleton-scoped production service must not
659
+ // silently degrade to Transient (captive-lifetime validation
660
+ // would reject the production dependents).
661
+ loadAs: componentScope(write.implementation) ?? knownLifetimes.get(token) ?? componentScope(token)
576
662
  });
577
663
  break;
578
664
  }
@@ -597,6 +683,9 @@ var TestIocBuilder = class _TestIocBuilder {
597
683
  break;
598
684
  }
599
685
  case "methods": {
686
+ if (write.byName && ambiguousNames.has(write.key)) {
687
+ throw new AmbiguousNameKeyError(write.key, "methods");
688
+ }
600
689
  const token = write.byName && knownByName.has(write.key) ? knownByName.get(write.key) : write.key;
601
690
  methodWrites.push({
602
691
  key: token,
@@ -670,8 +759,80 @@ var TestIocBuilder = class _TestIocBuilder {
670
759
  function testIoc(...inputs) {
671
760
  return TestIocBuilder.create(inputs);
672
761
  }
762
+
763
+ // src/seams.ts
764
+ var import_ioc2 = require("@noego/ioc");
765
+ var COMPONENT_OPTIONS_KEY2 = /* @__PURE__ */ Symbol.for("ioc:component:options");
766
+ function componentScope2(cls) {
767
+ const options = typeof Reflect !== "undefined" && Reflect.getMetadata ? Reflect.getMetadata(COMPONENT_OPTIONS_KEY2, cls) : void 0;
768
+ return options?.scope;
769
+ }
770
+ function* tupleEntries(config, space) {
771
+ if (Array.isArray(config)) {
772
+ for (const entry of config) {
773
+ if (!Array.isArray(entry) || entry.length !== 2) {
774
+ throw new InvalidDescriptorError(
775
+ `canonical ${space} entries are [token, value] tuples, e.g. .${space}([[Token, Impl]])`
776
+ );
777
+ }
778
+ yield [entry[0], entry[1]];
779
+ }
780
+ } else if (config instanceof Map) {
781
+ for (const [key, value] of config) yield [key, value];
782
+ } else {
783
+ throw new InvalidDescriptorError(
784
+ `installSeams accepts only exact-token ${space} entries (tuple array or Map); name-keyed records need the composition knowledge only testIoc() has.`
785
+ );
786
+ }
787
+ }
788
+ function registerClassBinding(root, token, implementation) {
789
+ const loadAs = componentScope2(implementation) ?? componentScope2(token) ?? import_ioc2.LoadAs.Singleton;
790
+ root.registerClass(implementation, { loadAs });
791
+ if (token === implementation) return;
792
+ if (loadAs === import_ioc2.LoadAs.Singleton) {
793
+ root.registerFunction(token, () => root.get(implementation), {
794
+ loadAs: import_ioc2.LoadAs.Singleton
795
+ });
796
+ } else {
797
+ root.registerFunction(token, (scope) => scope.get(implementation), {
798
+ loadAs,
799
+ param: [import_ioc2.SCOPED_CONTAINER]
800
+ });
801
+ }
802
+ }
803
+ function installSeams(root, config) {
804
+ if (typeof root.setInstanceDecorator !== "function") {
805
+ throw new MissingIocSeamError();
806
+ }
807
+ for (const [token, implementation] of tupleEntries(config.classes ?? [], "classes")) {
808
+ registerClassBinding(root, token, implementation);
809
+ }
810
+ for (const [token, value] of tupleEntries(config.values ?? [], "values")) {
811
+ root.registerFunction(token, () => value, { loadAs: import_ioc2.LoadAs.Singleton });
812
+ }
813
+ const registry = new WatchRegistry();
814
+ for (const [token, methodsInput] of tupleEntries(config.methods ?? [], "methods")) {
815
+ const methods = /* @__PURE__ */ new Map();
816
+ const entries = methodsInput instanceof Map ? methodsInput.entries() : Object.entries(methodsInput);
817
+ for (const [name, descriptor] of entries) {
818
+ if (typeof descriptor !== "function" && !isDescriptor(descriptor)) {
819
+ throw new InvalidDescriptorError(
820
+ `.methods entry ${tokenLabel(token)}.${name} must be a test.* descriptor or a raw wrapper function.`
821
+ );
822
+ }
823
+ methods.set(name, descriptor);
824
+ }
825
+ registry.addEntry({ key: token, byName: false, methods });
826
+ }
827
+ root.setInstanceDecorator(createMethodDecorator(registry));
828
+ return {
829
+ verify: async () => registry.verify(),
830
+ [ENV_REGISTRY]: registry
831
+ };
832
+ }
673
833
  // Annotate the CommonJS export names for ESM import in node:
674
834
  0 && (module.exports = {
835
+ AmbiguousNameKeyError,
675
836
  CallScriptExhaustedError,
676
837
  ENV_REGISTRY,
677
838
  ExpectationOverflowError,
@@ -681,9 +842,11 @@ function testIoc(...inputs) {
681
842
  NonObjectMethodTargetError,
682
843
  TestIocBuilder,
683
844
  TestingError,
845
+ TokenIdentitySplitError,
684
846
  UnknownTokenKeyError,
685
847
  UnwatchedInspectionError,
686
848
  VerificationError,
849
+ installSeams,
687
850
  test,
688
851
  testIoc
689
852
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/builder.ts","../src/errors.ts","../src/descriptors.ts","../src/method_state.ts"],"sourcesContent":["/**\n * @noego/testing — the canonical shared owner of real-IoC test composition\n * (`testIoc`) and the lowercase `test.*` method behavior/watch/expectation\n * language, built on @noego/ioc's production seams.\n *\n * The former generic runtime-mirror doubles (ManualClock, ScriptedFetchClient,\n * memory stores, recording sinks, contract suites, LeakDetector, …) are\n * retired; pin 0.1.x if you still need them, and see the NoEgo runtime/testing\n * deprecation plan for per-export dispositions.\n */\n\nexport { testIoc, TestIocBuilder } from './builder';\nexport type { TestEnvironment, ConfigMap, MethodsConfig, UseInput } from './builder';\n\nexport { test, ENV_REGISTRY } from './descriptors';\nexport type {\n BehaviorDescriptor,\n CallsDescriptor,\n ExpectationDescriptor,\n MethodDescriptor,\n MethodInspection,\n OriginalDescriptor,\n RawMethodWrapper,\n RecordedCall,\n ReturnsDescriptor,\n ThrowsDescriptor,\n WatchDescriptor,\n} from './descriptors';\n\nexport {\n TestingError,\n MissingIocSeamError,\n UnwatchedInspectionError,\n CallScriptExhaustedError,\n ExpectationOverflowError,\n VerificationError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnknownTokenKeyError,\n InvalidDescriptorError,\n} from './errors';\n","/**\n * `testIoc` — the canonical shared real-IoC test composition builder.\n *\n * Persistent immutable: every fluent call returns a new derived builder\n * sharing the ordered write log structurally. Non-conflicting writes are\n * order-insensitive; the last write to the same effective identity wins on\n * that derived branch. `.build()` is non-consuming and creates fresh runtime,\n * watch, and expectation state (spec 15, PBR-01..15).\n */\n\nimport {\n createContainer,\n flattenModule,\n LoadAs,\n SCOPED_CONTAINER,\n type ApplicationModule,\n type IContainer,\n} from '@noego/ioc';\n\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError, UnknownTokenKeyError } from './errors';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\n/** Config maps accept plain objects (string keys) or Maps (exact tokens). */\nexport type ConfigMap<V> = Record<string, V> | ReadonlyMap<Token, V>;\n\nexport type MethodsConfig = ConfigMap<Record<string, MethodDescriptor> | ReadonlyMap<string, MethodDescriptor>>;\n\nexport type UseInput = ApplicationModule | TestIocBuilder;\n\ntype Write =\n | { op: 'use'; module: ApplicationModule }\n | { op: 'classes'; key: Token; byName: boolean; implementation: ClassLike }\n | { op: 'functions'; key: Token; byName: boolean; factory: (...args: any[]) => any }\n | { op: 'values'; key: Token; byName: boolean; value: unknown }\n | { op: 'methods'; key: Token; byName: boolean; methods: ReadonlyMap<string, MethodDescriptor> };\n\nexport interface TestEnvironment {\n readonly root: IContainer;\n get<T>(token: unknown, params?: any[]): Promise<T> | T;\n instance<T>(cls: new (...args: any[]) => T, params?: any[]): Promise<T> | T;\n extend(): IContainer;\n verify(): Promise<void>;\n dispose(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction* configEntries<V>(config: ConfigMap<V>): Iterable<[Token, boolean, V]> {\n if (config instanceof Map) {\n for (const [key, value] of config) yield [key, false, value];\n } else {\n for (const key of [...Object.getOwnPropertyNames(config), ...Object.getOwnPropertySymbols(config)]) {\n yield [key, typeof key === 'string', (config as any)[key]];\n }\n }\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction lifetimeToLoadAs(lifetime: string): LoadAs {\n if (lifetime === 'singleton') return LoadAs.Singleton;\n if (lifetime === 'scoped') return LoadAs.Scoped;\n return LoadAs.Transient;\n}\n\nexport class TestIocBuilder {\n private constructor(private readonly log: readonly Write[]) {\n Object.freeze(this);\n }\n\n /** @internal */\n static create(inputs: readonly UseInput[]): TestIocBuilder {\n return new TestIocBuilder([]).useAll(inputs);\n }\n\n /** @internal — read by .use(builderPreset) */\n get writes(): readonly Write[] {\n return this.log;\n }\n\n private derive(writes: Write[]): TestIocBuilder {\n return new TestIocBuilder([...this.log, ...writes]);\n }\n\n private useAll(inputs: readonly UseInput[]): TestIocBuilder {\n let builder: TestIocBuilder = this;\n for (const input of inputs) builder = builder.use(input);\n return builder;\n }\n\n /** Apply a reusable composition preset: an ApplicationModule or a builder. */\n use(preset: UseInput): TestIocBuilder {\n if (preset instanceof TestIocBuilder) {\n return this.derive([...preset.writes]);\n }\n return this.derive([{ op: 'use', module: preset }]);\n }\n\n /** Replace the implementation for IoC class tokens in the built environment. */\n classes(config: ConfigMap<ClassLike>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, implementation] of configEntries(config)) {\n if (typeof implementation !== 'function' || !implementation.prototype) {\n throw new InvalidDescriptorError(\n `.classes() value for \"${tokenLabel(key)}\" must be a class constructor.`,\n );\n }\n writes.push({ op: 'classes', key, byName, implementation });\n }\n return this.derive(writes);\n }\n\n /** Replace IoC factory/provider registrations. */\n functions(config: ConfigMap<(...args: any[]) => any>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, factory] of configEntries(config)) {\n if (typeof factory !== 'function') {\n throw new InvalidDescriptorError(`.functions() value for \"${tokenLabel(key)}\" must be a function.`);\n }\n writes.push({ op: 'functions', key, byName, factory });\n }\n return this.derive(writes);\n }\n\n /** Provide/replace IoC value registrations. */\n values(config: ConfigMap<unknown>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, value] of configEntries(config)) {\n writes.push({ op: 'values', key, byName, value });\n }\n return this.derive(writes);\n }\n\n /** Install method behavior/observation descriptors on IoC-managed instances. */\n methods(config: MethodsConfig): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, methodsInput] of configEntries(config)) {\n const methods = new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods() entry ${tokenLabel(key)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n writes.push({ op: 'methods', key, byName, methods });\n }\n return this.derive(writes);\n }\n\n /** Materialize a fresh, isolated real-IoC environment. Non-consuming. */\n async build(): Promise<TestEnvironment> {\n const root = createContainer();\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n\n // ---- Materialize the ordered log: last write wins per effective identity\n // Known tokens (for resolving string keys of classes/functions/values)\n const knownByName = new Map<string, Token>();\n const knownLifetimes = new Map<Token, LoadAs>();\n const note = (token: Token, loadAs: LoadAs | undefined) => {\n if (typeof token === 'function' && (token as any).name) knownByName.set((token as any).name, token);\n else if (typeof token === 'string') knownByName.set(token, token);\n if (loadAs !== undefined) knownLifetimes.set(token, loadAs);\n };\n\n type Effective =\n | { space: 'class'; token: Token; implementation: ClassLike; loadAs?: LoadAs }\n | { space: 'factory'; token: Token; factory: (...args: any[]) => any; loadAs?: LoadAs; deps?: Token[] }\n | { space: 'value'; token: Token; value: unknown };\n\n // ordered map: identity → latest effective write (Map preserves first-write\n // position which is fine — later writes replace content, LWW)\n const effective = new Map<Token, Effective>();\n const methodWrites: { key: Token; byName: boolean; methods: Map<string, MethodDescriptor> }[] = [];\n\n const resolveKey = (key: Token, byName: boolean, space: string): Token => {\n if (!byName) return key;\n const known = knownByName.get(key as string);\n if (known !== undefined) return known;\n if (space === 'values' || space === 'functions') return key; // string tokens are first-class\n throw new UnknownTokenKeyError(key as string, space, [...knownByName.keys()]);\n };\n\n for (const write of this.log) {\n switch (write.op) {\n case 'use': {\n for (const reg of flattenModule(write.module)) {\n const loadAs = lifetimeToLoadAs(reg.lifetime);\n note(reg.token, loadAs);\n if (reg.kind === 'class') {\n note(reg.implementation as Token, loadAs);\n effective.set(reg.token, {\n space: 'class',\n token: reg.token,\n implementation: reg.implementation as ClassLike,\n loadAs,\n });\n knownLifetimes.set(reg.token, loadAs);\n knownLifetimes.set(reg.implementation as Token, loadAs);\n } else if (reg.kind === 'factory') {\n effective.set(reg.token, {\n space: 'factory',\n token: reg.token,\n factory: reg.implementation as (...args: any[]) => any,\n loadAs,\n deps: [...reg.dependencies],\n });\n } else {\n effective.set(reg.token, { space: 'value', token: reg.token, value: reg.implementation });\n knownLifetimes.set(reg.token, LoadAs.Singleton);\n }\n }\n break;\n }\n case 'classes': {\n const token = resolveKey(write.key, write.byName, 'classes');\n note(write.implementation, undefined);\n if (!write.byName) note(token, undefined);\n effective.set(token, {\n space: 'class',\n token,\n implementation: write.implementation,\n // preserve configured lifetime unless the replacement declares its own scope\n loadAs: componentScope(write.implementation) ?? knownLifetimes.get(token),\n });\n break;\n }\n case 'functions': {\n const token = resolveKey(write.key, write.byName, 'functions');\n const prior = effective.get(token);\n effective.set(token, {\n space: 'factory',\n token,\n factory: write.factory,\n // preserve configured lifetime unless the scenario overrides it\n loadAs: prior && prior.space === 'factory' ? prior.loadAs : knownLifetimes.get(token),\n deps: prior && prior.space === 'factory' ? prior.deps : undefined,\n });\n note(token, undefined);\n break;\n }\n case 'values': {\n const token = resolveKey(write.key, write.byName, 'values');\n effective.set(token, { space: 'value', token, value: write.value });\n note(token, LoadAs.Singleton);\n break;\n }\n case 'methods': {\n const token = write.byName && knownByName.has(write.key as string)\n ? knownByName.get(write.key as string)!\n : write.key;\n methodWrites.push({\n key: token,\n byName: write.byName && !knownByName.has(write.key as string),\n methods: new Map(write.methods),\n });\n break;\n }\n }\n }\n\n // ---- Apply effective registrations to the fresh root\n for (const entry of effective.values()) {\n if (entry.space === 'class') {\n this.registerClassBinding(root, entry.token, entry.implementation, entry.loadAs);\n } else if (entry.space === 'factory') {\n root.registerFunction(entry.token, entry.factory, {\n loadAs: entry.loadAs,\n param: entry.deps,\n } as any);\n } else {\n const value = entry.value;\n root.registerFunction(entry.token, () => value, { loadAs: LoadAs.Singleton } as any);\n }\n }\n\n // ---- Fresh watch/expectation state + the ioc decoration seam\n const registry = new WatchRegistry();\n // merge method writes: LWW per (entry key, method), deep-merge per token\n const mergedMethods = new Map<Token, { byName: boolean; methods: Map<string, MethodDescriptor> }>();\n for (const write of methodWrites) {\n const existing = mergedMethods.get(write.key);\n if (existing) {\n for (const [name, descriptor] of write.methods) existing.methods.set(name, descriptor);\n } else {\n mergedMethods.set(write.key, { byName: write.byName, methods: new Map(write.methods) });\n }\n }\n for (const [key, { byName, methods }] of mergedMethods) {\n registry.addEntry({ key, byName, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n const env: TestEnvironment = {\n root: root as IContainer,\n get: (token, params) => root.get(token as any, params),\n instance: (cls, params) => root.instance(cls, params),\n extend: () => root.extend() as IContainer,\n verify: async () => registry.verify(),\n dispose: () => root.dispose(),\n [ENV_REGISTRY]: registry,\n };\n return env;\n }\n\n /**\n * Register a class binding. When token === implementation this is a plain\n * class registration. Otherwise an alias factory resolves the implementation\n * through real IoC, mirroring the implementation's effective lifetime so\n * lifetime validation (captive-lifetime checks) stays honest.\n */\n private registerClassBinding(\n root: IContainer,\n token: Token,\n implementation: ClassLike,\n configuredLoadAs?: LoadAs,\n ): void {\n const loadAs = configuredLoadAs ?? componentScope(implementation) ?? LoadAs.Transient;\n root.registerClass(implementation as any, configuredLoadAs !== undefined ? ({ loadAs } as any) : undefined);\n if (token === implementation) return;\n\n if (loadAs === LoadAs.Singleton) {\n root.registerFunction(token, () => root.get(implementation as any), {\n loadAs: LoadAs.Singleton,\n } as any);\n } else {\n root.registerFunction(token, (scope: IContainer) => scope.get(implementation as any), {\n loadAs,\n param: [SCOPED_CONTAINER],\n } as any);\n }\n }\n}\n\n/** Create a persistent immutable real-IoC test composition builder. */\nexport function testIoc(...inputs: UseInput[]): TestIocBuilder {\n return TestIocBuilder.create(inputs);\n}\n","/**\n * Diagnostics are first-class: every error names the real token/method and\n * what was expected vs what happened, never only internal wrapper machinery.\n */\n\nexport class TestingError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/** Thrown at build() when the installed @noego/ioc lacks the decoration seam. */\nexport class MissingIocSeamError extends TestingError {\n constructor() {\n super(\n '@noego/testing requires an @noego/ioc version that provides ' +\n 'Container.setInstanceDecorator (>= 0.5.x with the instance-decoration seam). ' +\n 'Upgrade @noego/ioc.',\n );\n }\n}\n\n/** test.inspect() on a method that is not watched in this environment. */\nexport class UnwatchedInspectionError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Method \"${method}\" on ${token} is not watched in this environment. ` +\n 'Only watched methods are inspectable — install test.watch() or any ' +\n 'test.* behavior/expectation descriptor for it.',\n );\n }\n}\n\n/** A call arrived after a test.calls([...]) script was fully consumed. */\nexport class CallScriptExhaustedError extends TestingError {\n constructor(token: string, method: string, scriptLength: number, callIndex: number) {\n super(\n `Call #${callIndex} to ${token}.${method} exceeds its test.calls() script ` +\n `of ${scriptLength} ${scriptLength === 1 ? 'entry' : 'entries'}.`,\n );\n }\n}\n\n/** An exact expectation (once/times/never) was exceeded at call time. */\nexport class ExpectationOverflowError extends TestingError {\n constructor(token: string, method: string, expected: number, attempted: number) {\n super(\n expected === 0\n ? `${token}.${method} was expected never to be called, but it was invoked.`\n : `${token}.${method} was expected exactly ${expected} ` +\n `${expected === 1 ? 'call' : 'calls'}, but call #${attempted} arrived.`,\n );\n }\n}\n\n/** Aggregated under-count failures reported by env.verify(). */\nexport class VerificationError extends TestingError {\n constructor(failures: readonly { token: string; method: string; expected: number; actual: number }[]) {\n super(\n 'Exact method expectations were not satisfied:\\n' +\n failures\n .map(\n (f) =>\n ` - ${f.token}.${f.method}: expected exactly ${f.expected} ` +\n `${f.expected === 1 ? 'call' : 'calls'}, observed ${f.actual}`,\n )\n .join('\\n'),\n );\n }\n}\n\n/** .methods configured for a token whose resolved value has no such callable method. */\nexport class MethodNotCallableError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Cannot install a test.* descriptor on ${token}.${method}: the resolved ` +\n 'instance has no callable method with that name.',\n );\n }\n}\n\n/** .methods configured for a token that resolved to a non-object value. */\nexport class NonObjectMethodTargetError extends TestingError {\n constructor(token: string) {\n super(\n `.methods() is configured for ${token}, but that token resolved to a ` +\n 'non-object value. Method descriptors apply only to IoC-managed instances.',\n );\n }\n}\n\n/** A string configuration key could not be resolved to a known IoC token. */\nexport class UnknownTokenKeyError extends TestingError {\n constructor(key: string, space: string, known: readonly string[]) {\n super(\n `Unknown ${space} key \"${key}\" — it does not match any token known to this ` +\n 'builder. Pass the class/token itself via a Map, or include the ' +\n 'registration through .use(...). Known tokens: ' +\n (known.length ? known.join(', ') : '(none)'),\n );\n }\n}\n\n/** Invalid descriptor construction (e.g. test.times(-1)). */\nexport class InvalidDescriptorError extends TestingError {}\n","/**\n * Lowercase `test.*` descriptors — immutable frozen values.\n *\n * Descriptors carry NO mutable state (no cursors, no counters, no histories);\n * all mutable invocation state lives in the built environment, so one\n * descriptor value is safe to share across builders and repeated builds.\n */\n\nimport { InvalidDescriptorError } from './errors';\n\nexport const DESCRIPTOR = Symbol.for('noego:testing:descriptor');\n\n/** A raw custom method wrapper: (original) => replacement. NOT auto-watched. */\nexport type RawMethodWrapper = (\n original: (...args: any[]) => any,\n) => (...args: any[]) => any;\n\nexport interface ReturnsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'returns';\n readonly value: unknown;\n}\n\nexport interface ThrowsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'throws';\n readonly error: unknown;\n}\n\nexport interface OriginalDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'original';\n}\n\nexport interface CallsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'calls';\n readonly script: readonly BehaviorDescriptor[];\n}\n\nexport type BehaviorDescriptor =\n | ReturnsDescriptor\n | ThrowsDescriptor\n | OriginalDescriptor\n | CallsDescriptor;\n\nexport interface WatchDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'watch';\n readonly wrapper?: RawMethodWrapper;\n}\n\nexport interface ExpectationDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'expect';\n /** Exact required call count; 0 for never(). */\n readonly expected: number;\n /** Behavior used for allowed calls; undefined = original effective behavior. */\n readonly behavior?: BehaviorDescriptor;\n}\n\n/** Everything installable through .methods({...}). */\nexport type MethodDescriptor =\n | BehaviorDescriptor\n | WatchDescriptor\n | ExpectationDescriptor\n | RawMethodWrapper;\n\nexport function isDescriptor(value: unknown): value is Exclude<MethodDescriptor, RawMethodWrapper> {\n return typeof value === 'object' && value !== null && (value as any)[DESCRIPTOR] === true;\n}\n\nfunction frozen<T extends object>(value: T): T {\n return Object.freeze(value);\n}\n\nfunction assertBehavior(value: unknown, where: string): asserts value is BehaviorDescriptor {\n if (!isDescriptor(value) || !['returns', 'throws', 'original', 'calls'].includes((value as any).kind)) {\n throw new InvalidDescriptorError(\n `${where} requires a behavior descriptor (test.returns/throws/original/calls).`,\n );\n }\n}\n\nexport const test = {\n /** Return the supplied value when the method is called. Auto-watches. */\n returns(value: unknown): ReturnsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'returns' as const, value });\n },\n\n /** Throw/reject with the supplied error. Auto-watches. */\n throws(error: unknown): ThrowsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'throws' as const, error });\n },\n\n /** Invoke the original effective method. Auto-watches. */\n original(): OriginalDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'original' as const });\n },\n\n /**\n * Per-invocation behavior script: call 1 uses entry 1, and so on. A call\n * after exhaustion fails immediately. Unused entries do not fail verification.\n */\n calls(script: readonly BehaviorDescriptor[]): CallsDescriptor {\n if (!Array.isArray(script)) {\n throw new InvalidDescriptorError('test.calls() requires an array of behavior descriptors.');\n }\n script.forEach((entry, i) => assertBehavior(entry, `test.calls() entry #${i + 1}`));\n return frozen({ [DESCRIPTOR]: true as const, kind: 'calls' as const, script: Object.freeze([...script]) });\n },\n\n /**\n * Keep original behavior and record calls. With a raw wrapper argument, the\n * wrapper's behavior runs and is recorded.\n */\n watch(wrapper?: RawMethodWrapper): WatchDescriptor {\n if (wrapper !== undefined && typeof wrapper !== 'function') {\n throw new InvalidDescriptorError('test.watch() accepts only a raw wrapper function.');\n }\n return frozen({ [DESCRIPTOR]: true as const, kind: 'watch' as const, wrapper });\n },\n\n /** Require exactly one call; with no behavior, the original runs. */\n once(behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (behavior !== undefined) assertBehavior(behavior, 'test.once()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 1, behavior });\n },\n\n /** Require exactly `count` calls; with no behavior, the original runs. */\n times(count: number, behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (!Number.isInteger(count) || count < 0) {\n throw new InvalidDescriptorError(\n `test.times() requires a non-negative integer count, received ${String(count)}.`,\n );\n }\n if (behavior !== undefined) assertBehavior(behavior, 'test.times()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: count, behavior });\n },\n\n /** Require zero calls; the first invocation fails and skips the original. */\n never(): ExpectationDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 0 });\n },\n\n /** Read the recorded history for a watched method in one environment. */\n inspect(environment: unknown, token: unknown, method: string): MethodInspection {\n const registry = (environment as any)?.[ENV_REGISTRY];\n if (!registry) {\n throw new InvalidDescriptorError(\n 'test.inspect() requires a built @noego/testing environment as its first argument.',\n );\n }\n return registry.inspect(token, method);\n },\n};\n\nObject.freeze(test);\n\n/** Symbol under which a built environment exposes its watch registry. */\nexport const ENV_REGISTRY = Symbol.for('noego:testing:env-registry');\n\nexport interface RecordedCall {\n /** 1-based invocation index in this environment. */\n readonly index: number;\n readonly args: readonly unknown[];\n /** Present once the call returned (resolved value for async methods). */\n readonly result?: unknown;\n /** Present once the call threw/rejected. */\n readonly error?: unknown;\n /** True while an async outcome is still pending. */\n readonly pending: boolean;\n readonly timestamp: number;\n}\n\nexport interface MethodInspection {\n readonly count: number;\n readonly calls: readonly RecordedCall[];\n}\n","/**\n * Environment-owned method behavior/observation runtime.\n *\n * All mutable state (histories, expectation counters, calls-script cursors)\n * lives here, created fresh at every build(). Descriptors stay immutable.\n */\n\nimport {\n type BehaviorDescriptor,\n type ExpectationDescriptor,\n type MethodDescriptor,\n type MethodInspection,\n type RawMethodWrapper,\n type RecordedCall,\n isDescriptor,\n} from './descriptors';\nimport {\n CallScriptExhaustedError,\n ExpectationOverflowError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnwatchedInspectionError,\n VerificationError,\n} from './errors';\n\nconst CONTEXT_WRAPPED = Symbol.for('ioc:context-wrapped');\nconst CONTEXT_OWNER = Symbol.for('ioc:context-owner');\n\nexport function tokenLabel(token: unknown): string {\n if (typeof token === 'function') return (token as { name?: string }).name || '[anonymous class]';\n if (typeof token === 'symbol') return String(token);\n return String(token);\n}\n\ninterface MutableCall {\n index: number;\n args: readonly unknown[];\n result?: unknown;\n error?: unknown;\n pending: boolean;\n timestamp: number;\n}\n\nexport class MethodState {\n readonly calls: MutableCall[] = [];\n /** Actual invocation count (includes the call currently executing). */\n actual = 0;\n /** Cursor into a test.calls() script. */\n scriptCursor = 0;\n\n constructor(\n readonly tokenName: string,\n readonly method: string,\n readonly descriptor: Exclude<MethodDescriptor, RawMethodWrapper>,\n ) {}\n\n get expectation(): ExpectationDescriptor | undefined {\n return this.descriptor.kind === 'expect' ? this.descriptor : undefined;\n }\n\n inspection(): MethodInspection {\n return {\n count: this.calls.length,\n calls: this.calls.map((c) => ({ ...c, args: [...c.args] }) as RecordedCall),\n };\n }\n}\n\n/** One method-config entry: how it was keyed, and its per-method descriptors. */\nexport interface MethodConfigEntry {\n /** Exact token (class/symbol/string) or a name string matched lazily. */\n readonly key: unknown;\n readonly byName: boolean;\n readonly methods: ReadonlyMap<string, MethodDescriptor>;\n}\n\nexport class WatchRegistry {\n /** entry-identity → method → state. Entries share states across instances. */\n private readonly states = new Map<unknown, Map<string, MethodState>>();\n private readonly nameIndex = new Map<string, unknown>();\n private readonly entries: MethodConfigEntry[] = [];\n\n addEntry(entry: MethodConfigEntry): void {\n this.entries.push(entry);\n const byMethod = new Map<string, MethodState>();\n for (const [method, descriptor] of entry.methods) {\n if (typeof descriptor === 'function') continue; // raw wrapper: unwatched, no state\n byMethod.set(method, new MethodState(this.entryLabel(entry), method, descriptor));\n }\n this.states.set(entry.key, byMethod);\n if (entry.byName) this.nameIndex.set(entry.key as string, entry.key);\n else if (typeof entry.key === 'function' && (entry.key as any).name) {\n this.nameIndex.set((entry.key as any).name, entry.key);\n }\n }\n\n private entryLabel(entry: MethodConfigEntry): string {\n return entry.byName ? String(entry.key) : tokenLabel(entry.key);\n }\n\n /** Entries applying to a resolving token (exact identity or name match). */\n matchEntries(token: unknown): MethodConfigEntry[] {\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n return this.entries.filter(\n (entry) => entry.key === token || (entry.byName && name !== undefined && entry.key === name),\n );\n }\n\n state(entryKey: unknown, method: string): MethodState | undefined {\n return this.states.get(entryKey)?.get(method);\n }\n\n inspect(token: unknown, method: string): MethodInspection {\n const label = tokenLabel(token);\n const keys: unknown[] = [token];\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n if (name !== undefined && this.nameIndex.has(name)) keys.push(this.nameIndex.get(name));\n for (const key of keys) {\n const state = this.states.get(key)?.get(method);\n if (state) return state.inspection();\n }\n throw new UnwatchedInspectionError(label, method);\n }\n\n /** Repeatable snapshot check of all exact expectations. */\n verify(): void {\n const failures: { token: string; method: string; expected: number; actual: number }[] = [];\n for (const byMethod of this.states.values()) {\n for (const state of byMethod.values()) {\n const expectation = state.expectation;\n if (!expectation) continue;\n if (state.actual !== expectation.expected) {\n failures.push({\n token: state.tokenName,\n method: state.method,\n expected: expectation.expected,\n actual: state.actual,\n });\n }\n }\n }\n if (failures.length) throw new VerificationError(failures);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as any).then === 'function';\n}\n\nfunction recordOutcome(call: MutableCall, outcome: unknown, threw: boolean): unknown {\n if (!threw && isPromiseLike(outcome)) {\n call.pending = true;\n outcome.then(\n (value) => {\n call.result = value;\n call.pending = false;\n },\n (error) => {\n call.error = error;\n call.pending = false;\n },\n );\n return outcome;\n }\n call.pending = false;\n if (threw) call.error = outcome;\n else call.result = outcome;\n return outcome;\n}\n\n/**\n * Build the ioc instance decorator for one environment.\n *\n * Identity-stable (WeakMap), preserves sync/async call shape and `this`\n * binding, forwards the ioc context symbols by delegating to the underlying\n * (context-wrapped) target for everything unconfigured.\n */\nexport function createMethodDecorator(registry: WatchRegistry): (instance: any, token: any) => any {\n const wrappers = new WeakMap<object, any>();\n\n return function decorate(instance: any, token: any): any {\n const entries = registry.matchEntries(token);\n if (entries.length === 0) return instance;\n\n if (instance === null || (typeof instance !== 'object' && typeof instance !== 'function')) {\n throw new NonObjectMethodTargetError(tokenLabel(token));\n }\n\n if (wrappers.has(instance)) return wrappers.get(instance);\n\n // Effective per-method config: entries merge in write order, LWW per method\n const effective = new Map<string, { entryKey: unknown; descriptor: MethodDescriptor }>();\n for (const entry of entries) {\n for (const [method, descriptor] of entry.methods) {\n effective.set(method, { entryKey: entry.key, descriptor });\n }\n }\n\n // Validate configured methods exist and are callable\n for (const method of effective.keys()) {\n if (typeof instance[method] !== 'function') {\n throw new MethodNotCallableError(tokenLabel(token), method);\n }\n }\n\n const methodCache = new Map<string, (...args: any[]) => any>();\n\n const proxy = new Proxy(instance, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && effective.has(prop)) {\n let wrapped = methodCache.get(prop);\n if (!wrapped) {\n const { entryKey, descriptor } = effective.get(prop)!;\n wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));\n methodCache.set(prop, wrapped);\n }\n return wrapped;\n }\n // Everything else (including ioc context symbols) delegates to the\n // underlying — usually context-wrapped — target.\n if (prop === CONTEXT_WRAPPED || prop === CONTEXT_OWNER) return (target as any)[prop];\n return Reflect.get(target, prop, receiver);\n },\n });\n\n wrappers.set(instance, proxy);\n return proxy;\n };\n}\n\nfunction buildMethodWrapper(\n target: any,\n method: string,\n descriptor: MethodDescriptor,\n state: MethodState | undefined,\n): (...args: any[]) => any {\n // The original effective method, read through the underlying target so the\n // ioc context proxy still owns context entry for real invocations.\n const callOriginal = (self: any, args: any[]) => {\n const fn = target[method];\n return fn.apply(self === undefined ? target : self, args);\n };\n\n // Raw custom wrapper: installed as-is, NOT watched, no recording.\n if (typeof descriptor === 'function') {\n const replacement = descriptor((...args: any[]) => callOriginal(target, args));\n return function (this: any, ...args: any[]) {\n return replacement.apply(this, args);\n };\n }\n\n if (!isDescriptor(descriptor)) {\n // Should be unreachable: builder validates descriptors on write.\n throw new TypeError(`Invalid method descriptor for ${method}`);\n }\n\n return function (this: any, ...args: any[]) {\n if (!state) throw new TypeError(`Missing method state for ${method}`);\n\n const expectation = state.expectation;\n const attempted = state.actual + 1;\n\n // Overflow fails immediately and never runs behavior/original\n if (expectation && attempted > expectation.expected) {\n state.actual = attempted;\n throw new ExpectationOverflowError(state.tokenName, method, expectation.expected, attempted);\n }\n\n state.actual = attempted;\n const call: MutableCall = {\n index: attempted,\n args: [...args],\n pending: false,\n timestamp: Date.now(),\n };\n state.calls.push(call);\n\n // Effective behavior for this invocation\n let behavior: BehaviorDescriptor | 'original-effective' | RawMethodWrapper;\n const base =\n descriptor.kind === 'expect'\n ? (descriptor.behavior ?? 'original-effective')\n : descriptor.kind === 'watch'\n ? (descriptor.wrapper ?? 'original-effective')\n : descriptor;\n\n if (base !== 'original-effective' && typeof base !== 'function' && base !== undefined && base.kind === 'calls') {\n if (state.scriptCursor >= base.script.length) {\n throw new CallScriptExhaustedError(state.tokenName, method, base.script.length, attempted);\n }\n behavior = base.script[state.scriptCursor]!;\n state.scriptCursor += 1;\n } else {\n behavior = base;\n }\n\n try {\n let outcome: unknown;\n if (behavior === 'original-effective') {\n outcome = callOriginal(this, args);\n } else if (typeof behavior === 'function') {\n // test.watch(rawWrapper): wrapper behavior runs and is recorded\n outcome = behavior((...inner: any[]) => callOriginal(this, inner)).apply(this, args);\n } else if (behavior.kind === 'returns') {\n outcome = behavior.value;\n } else if (behavior.kind === 'throws') {\n throw behavior.error;\n } else if (behavior.kind === 'original') {\n outcome = callOriginal(this, args);\n } else {\n throw new TypeError(`Nested test.calls() scripts are not supported (${method}).`);\n }\n return recordOutcome(call, outcome, false);\n } catch (error) {\n recordOutcome(call, error, true);\n throw error;\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,iBAOO;;;ACZA,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,cAAc;AACZ;AAAA,MACE;AAAA,IAGF;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAY,OAAe,QAAgB;AACzC;AAAA,MACE,WAAW,MAAM,QAAQ,KAAK;AAAA,IAGhC;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAY,OAAe,QAAgB,cAAsB,WAAmB;AAClF;AAAA,MACE,SAAS,SAAS,OAAO,KAAK,IAAI,MAAM,uCAChC,YAAY,IAAI,iBAAiB,IAAI,UAAU,SAAS;AAAA,IAClE;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAY,OAAe,QAAgB,UAAkB,WAAmB;AAC9E;AAAA,MACE,aAAa,IACT,GAAG,KAAK,IAAI,MAAM,0DAClB,GAAG,KAAK,IAAI,MAAM,yBAAyB,QAAQ,IAChD,aAAa,IAAI,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,QAAQ,QAAQ,CAAC;AAAA,IAC5C;AACA,IAAC,KAAa,qBAAqB,sBAAsB,QAAQ,CAAC;AAElE,UAAM,MAAuB;AAAA,MAC3B;AAAA,MACA,KAAK,CAAC,OAAO,WAAW,KAAK,IAAI,OAAc,MAAM;AAAA,MACrD,UAAU,CAAC,KAAK,WAAW,KAAK,SAAS,KAAK,MAAM;AAAA,MACpD,QAAQ,MAAM,KAAK,OAAO;AAAA,MAC1B,QAAQ,YAAY,SAAS,OAAO;AAAA,MACpC,SAAS,MAAM,KAAK,QAAQ;AAAA,MAC5B,CAAC,YAAY,GAAG;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQQ,qBACN,MACA,OACA,gBACA,kBACM;AACN,UAAM,SAAS,oBAAoB,eAAe,cAAc,KAAK,kBAAO;AAC5E,SAAK,cAAc,gBAAuB,qBAAqB,SAAa,EAAE,OAAO,IAAY,MAAS;AAC1G,QAAI,UAAU,eAAgB;AAE9B,QAAI,WAAW,kBAAO,WAAW;AAC/B,WAAK,iBAAiB,OAAO,MAAM,KAAK,IAAI,cAAqB,GAAG;AAAA,QAClE,QAAQ,kBAAO;AAAA,MACjB,CAAQ;AAAA,IACV,OAAO;AACL,WAAK,iBAAiB,OAAO,CAAC,UAAsB,MAAM,IAAI,cAAqB,GAAG;AAAA,QACpF;AAAA,QACA,OAAO,CAAC,2BAAgB;AAAA,MAC1B,CAAQ;AAAA,IACV;AAAA,EACF;AACF;AAGO,SAAS,WAAW,QAAoC;AAC7D,SAAO,eAAe,OAAO,MAAM;AACrC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/builder.ts","../src/errors.ts","../src/descriptors.ts","../src/method_state.ts","../src/seams.ts"],"sourcesContent":["/**\n * @noego/testing — the canonical shared owner of real-IoC test composition\n * (`testIoc`) and the lowercase `test.*` method behavior/watch/expectation\n * language, built on @noego/ioc's production seams.\n *\n * The former generic runtime-mirror doubles (ManualClock, ScriptedFetchClient,\n * memory stores, recording sinks, contract suites, LeakDetector, …) are\n * retired; pin 0.1.x if you still need them, and see the NoEgo runtime/testing\n * deprecation plan for per-export dispositions.\n */\n\nexport { testIoc, TestIocBuilder } from './builder';\nexport type { TestEnvironment, ConfigMap, MethodsConfig, UseInput } from './builder';\n\nexport { test, ENV_REGISTRY } from './descriptors';\nexport type {\n BehaviorDescriptor,\n CallsDescriptor,\n ExpectationDescriptor,\n MethodDescriptor,\n MethodInspection,\n OriginalDescriptor,\n RawMethodWrapper,\n RecordedCall,\n ReturnsDescriptor,\n ThrowsDescriptor,\n WatchDescriptor,\n} from './descriptors';\n\nexport {\n TestingError,\n MissingIocSeamError,\n UnwatchedInspectionError,\n CallScriptExhaustedError,\n ExpectationOverflowError,\n VerificationError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnknownTokenKeyError,\n AmbiguousNameKeyError,\n TokenIdentitySplitError,\n InvalidDescriptorError,\n} from './errors';\n\nexport { installSeams } from './seams';\nexport type { SeamsConfig, InstalledSeams } from './seams';\n","/**\n * `testIoc` — the canonical shared real-IoC test composition builder.\n *\n * Persistent immutable: every fluent call returns a new derived builder\n * sharing the ordered write log structurally. Non-conflicting writes are\n * order-insensitive; the last write to the same effective identity wins on\n * that derived branch. `.build()` is non-consuming and creates fresh runtime,\n * watch, and expectation state (spec 15, PBR-01..15).\n */\n\nimport {\n createContainer,\n flattenModule,\n LoadAs,\n SCOPED_CONTAINER,\n type ApplicationModule,\n type IContainer,\n} from '@noego/ioc';\n\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError, UnknownTokenKeyError, AmbiguousNameKeyError,\n} from './errors';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\n/** Config maps accept plain objects (string keys) or Maps (exact tokens). */\n/**\n * Composition input (spec 04 §2). The CANONICAL entry form is an array of\n * tuples — token-first, exact identity:\n *\n * .classes([[ProjectRepository, MemoryProjectRepository]])\n *\n * A `ReadonlyMap<Token, V>` is equivalent (token-keyed). A name-keyed\n * `Record<string, V>` remains accepted as COMPATIBILITY input: string keys\n * resolve against known token display names, fail on unknown names, and\n * fail on ambiguous names (two tokens sharing one display name never\n * collapse into one entry — tokens are identities, names are labels).\n */\nexport type ConfigMap<V> =\n | ReadonlyArray<readonly [Token, V]>\n | ReadonlyMap<Token, V>\n | Record<string, V>;\n\nexport type MethodsConfig = ConfigMap<Record<string, MethodDescriptor> | ReadonlyMap<string, MethodDescriptor>>;\n\nexport type UseInput = ApplicationModule | TestIocBuilder;\n\ntype Write =\n | { op: 'use'; module: ApplicationModule }\n | { op: 'classes'; key: Token; byName: boolean; implementation: ClassLike }\n | { op: 'functions'; key: Token; byName: boolean; factory: (...args: any[]) => any }\n | { op: 'values'; key: Token; byName: boolean; value: unknown }\n | { op: 'methods'; key: Token; byName: boolean; methods: ReadonlyMap<string, MethodDescriptor> };\n\nexport interface BuildOptions {\n /** Compose production registrations on the fresh root before the seams. */\n prepare?: (root: IContainer) => void | Promise<void>;\n}\n\nexport interface TestEnvironment {\n readonly root: IContainer;\n get<T>(token: unknown, params?: any[]): Promise<T> | T;\n instance<T>(cls: new (...args: any[]) => T, params?: any[]): Promise<T> | T;\n extend(): IContainer;\n verify(): Promise<void>;\n dispose(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction* configEntries<V>(config: ConfigMap<V>): Iterable<[Token, boolean, V]> {\n if (Array.isArray(config)) {\n // Canonical tuple form: exact token identity, never name resolution.\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n 'canonical composition entries are [token, value] tuples, e.g. .classes([[Token, Impl]])',\n );\n }\n yield [entry[0], false, entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, false, value];\n } else {\n for (const key of [...Object.getOwnPropertyNames(config), ...Object.getOwnPropertySymbols(config)]) {\n yield [key, typeof key === 'string', (config as any)[key]];\n }\n }\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction lifetimeToLoadAs(lifetime: string): LoadAs {\n if (lifetime === 'singleton') return LoadAs.Singleton;\n if (lifetime === 'scoped') return LoadAs.Scoped;\n return LoadAs.Transient;\n}\n\nexport class TestIocBuilder {\n private constructor(private readonly log: readonly Write[]) {\n Object.freeze(this);\n }\n\n /** @internal */\n static create(inputs: readonly UseInput[]): TestIocBuilder {\n return new TestIocBuilder([]).useAll(inputs);\n }\n\n /** @internal — read by .use(builderPreset) */\n get writes(): readonly Write[] {\n return this.log;\n }\n\n private derive(writes: Write[]): TestIocBuilder {\n return new TestIocBuilder([...this.log, ...writes]);\n }\n\n private useAll(inputs: readonly UseInput[]): TestIocBuilder {\n let builder: TestIocBuilder = this;\n for (const input of inputs) builder = builder.use(input);\n return builder;\n }\n\n /** Apply a reusable composition preset: an ApplicationModule or a builder. */\n use(preset: UseInput): TestIocBuilder {\n if (preset instanceof TestIocBuilder) {\n return this.derive([...preset.writes]);\n }\n return this.derive([{ op: 'use', module: preset }]);\n }\n\n /** Replace the implementation for IoC class tokens in the built environment. */\n classes(config: ConfigMap<ClassLike>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, implementation] of configEntries(config)) {\n if (typeof implementation !== 'function' || !implementation.prototype) {\n throw new InvalidDescriptorError(\n `.classes() value for \"${tokenLabel(key)}\" must be a class constructor.`,\n );\n }\n writes.push({ op: 'classes', key, byName, implementation });\n }\n return this.derive(writes);\n }\n\n /** Replace IoC factory/provider registrations. */\n functions(config: ConfigMap<(...args: any[]) => any>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, factory] of configEntries(config)) {\n if (typeof factory !== 'function') {\n throw new InvalidDescriptorError(`.functions() value for \"${tokenLabel(key)}\" must be a function.`);\n }\n writes.push({ op: 'functions', key, byName, factory });\n }\n return this.derive(writes);\n }\n\n /** Provide/replace IoC value registrations. */\n values(config: ConfigMap<unknown>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, value] of configEntries(config)) {\n writes.push({ op: 'values', key, byName, value });\n }\n return this.derive(writes);\n }\n\n /** Install method behavior/observation descriptors on IoC-managed instances. */\n methods(config: MethodsConfig): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, methodsInput] of configEntries(config)) {\n const methods = new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods() entry ${tokenLabel(key)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n writes.push({ op: 'methods', key, byName, methods });\n }\n return this.derive(writes);\n }\n\n /**\n * Materialize a fresh, isolated real-IoC environment. Non-consuming.\n *\n * `prepare` runs on the fresh root BEFORE this builder's registrations and\n * the method-control decorator are applied: the place for an application's\n * production composition, so every declared seam shadows what production\n * registered for the same token, and instances constructed later are\n * decorated. Instances `prepare` constructs itself are not decorated.\n */\n async build(options: BuildOptions = {}): Promise<TestEnvironment> {\n const root = createContainer();\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n await options.prepare?.(root as IContainer);\n\n // ---- Materialize the ordered log: last write wins per effective identity\n // Known tokens (for resolving string keys of classes/functions/values)\n const knownByName = new Map<string, Token>();\n /** Display names claimed by more than one distinct token (spec 04 §5/§17). */\n const ambiguousNames = new Set<string>();\n const knownLifetimes = new Map<Token, LoadAs>();\n const note = (token: Token, loadAs: LoadAs | undefined) => {\n const name =\n typeof token === 'function' && (token as any).name\n ? (token as any).name as string\n : typeof token === 'string'\n ? token\n : null;\n if (name !== null) {\n const existing = knownByName.get(name);\n if (existing !== undefined && existing !== token) ambiguousNames.add(name);\n knownByName.set(name, token);\n }\n if (loadAs !== undefined) knownLifetimes.set(token, loadAs);\n };\n\n type Effective =\n | { space: 'class'; token: Token; implementation: ClassLike; loadAs?: LoadAs }\n | { space: 'factory'; token: Token; factory: (...args: any[]) => any; loadAs?: LoadAs; deps?: Token[] }\n | { space: 'value'; token: Token; value: unknown };\n\n // ordered map: identity → latest effective write (Map preserves first-write\n // position which is fine — later writes replace content, LWW)\n const effective = new Map<Token, Effective>();\n const methodWrites: { key: Token; byName: boolean; methods: Map<string, MethodDescriptor> }[] = [];\n\n const resolveKey = (key: Token, byName: boolean, space: string): Token => {\n if (!byName) return key;\n if (ambiguousNames.has(key as string)) {\n throw new AmbiguousNameKeyError(key as string, space);\n }\n const known = knownByName.get(key as string);\n if (known !== undefined) return known;\n if (space === 'values' || space === 'functions') return key; // string tokens are first-class\n throw new UnknownTokenKeyError(key as string, space, [...knownByName.keys()]);\n };\n\n for (const write of this.log) {\n switch (write.op) {\n case 'use': {\n for (const reg of flattenModule(write.module)) {\n const loadAs = lifetimeToLoadAs(reg.lifetime);\n note(reg.token, loadAs);\n if (reg.kind === 'class') {\n note(reg.implementation as Token, loadAs);\n effective.set(reg.token, {\n space: 'class',\n token: reg.token,\n implementation: reg.implementation as ClassLike,\n loadAs,\n });\n knownLifetimes.set(reg.token, loadAs);\n knownLifetimes.set(reg.implementation as Token, loadAs);\n } else if (reg.kind === 'factory') {\n effective.set(reg.token, {\n space: 'factory',\n token: reg.token,\n factory: reg.implementation as (...args: any[]) => any,\n loadAs,\n deps: [...reg.dependencies],\n });\n } else {\n effective.set(reg.token, { space: 'value', token: reg.token, value: reg.implementation });\n knownLifetimes.set(reg.token, LoadAs.Singleton);\n }\n }\n break;\n }\n case 'classes': {\n const token = resolveKey(write.key, write.byName, 'classes');\n note(write.implementation, undefined);\n if (!write.byName) note(token, undefined);\n effective.set(token, {\n space: 'class',\n token,\n implementation: write.implementation,\n // Lifetime priority: the replacement's own @Component scope, then\n // the lifetime the composition already knows for the token, then\n // the TOKEN class's declared @Component scope — a plain stub\n // class replacing a Singleton-scoped production service must not\n // silently degrade to Transient (captive-lifetime validation\n // would reject the production dependents).\n loadAs:\n componentScope(write.implementation)\n ?? knownLifetimes.get(token)\n ?? componentScope(token),\n });\n break;\n }\n case 'functions': {\n const token = resolveKey(write.key, write.byName, 'functions');\n const prior = effective.get(token);\n effective.set(token, {\n space: 'factory',\n token,\n factory: write.factory,\n // preserve configured lifetime unless the scenario overrides it\n loadAs: prior && prior.space === 'factory' ? prior.loadAs : knownLifetimes.get(token),\n deps: prior && prior.space === 'factory' ? prior.deps : undefined,\n });\n note(token, undefined);\n break;\n }\n case 'values': {\n const token = resolveKey(write.key, write.byName, 'values');\n effective.set(token, { space: 'value', token, value: write.value });\n note(token, LoadAs.Singleton);\n break;\n }\n case 'methods': {\n if (write.byName && ambiguousNames.has(write.key as string)) {\n throw new AmbiguousNameKeyError(write.key as string, 'methods');\n }\n const token = write.byName && knownByName.has(write.key as string)\n ? knownByName.get(write.key as string)!\n : write.key;\n methodWrites.push({\n key: token,\n byName: write.byName && !knownByName.has(write.key as string),\n methods: new Map(write.methods),\n });\n break;\n }\n }\n }\n\n // ---- Apply effective registrations to the fresh root\n for (const entry of effective.values()) {\n if (entry.space === 'class') {\n this.registerClassBinding(root, entry.token, entry.implementation, entry.loadAs);\n } else if (entry.space === 'factory') {\n root.registerFunction(entry.token, entry.factory, {\n loadAs: entry.loadAs,\n param: entry.deps,\n } as any);\n } else {\n const value = entry.value;\n root.registerFunction(entry.token, () => value, { loadAs: LoadAs.Singleton } as any);\n }\n }\n\n // ---- Fresh watch/expectation state + the ioc decoration seam\n const registry = new WatchRegistry();\n // merge method writes: LWW per (entry key, method), deep-merge per token\n const mergedMethods = new Map<Token, { byName: boolean; methods: Map<string, MethodDescriptor> }>();\n for (const write of methodWrites) {\n const existing = mergedMethods.get(write.key);\n if (existing) {\n for (const [name, descriptor] of write.methods) existing.methods.set(name, descriptor);\n } else {\n mergedMethods.set(write.key, { byName: write.byName, methods: new Map(write.methods) });\n }\n }\n for (const [key, { byName, methods }] of mergedMethods) {\n registry.addEntry({ key, byName, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n const env: TestEnvironment = {\n root: root as IContainer,\n get: (token, params) => root.get(token as any, params),\n instance: (cls, params) => root.instance(cls, params),\n extend: () => root.extend() as IContainer,\n verify: async () => registry.verify(),\n dispose: () => root.dispose(),\n [ENV_REGISTRY]: registry,\n };\n return env;\n }\n\n /**\n * Register a class binding. When token === implementation this is a plain\n * class registration. Otherwise an alias factory resolves the implementation\n * through real IoC, mirroring the implementation's effective lifetime so\n * lifetime validation (captive-lifetime checks) stays honest.\n */\n private registerClassBinding(\n root: IContainer,\n token: Token,\n implementation: ClassLike,\n configuredLoadAs?: LoadAs,\n ): void {\n const loadAs = configuredLoadAs ?? componentScope(implementation) ?? LoadAs.Transient;\n root.registerClass(implementation as any, configuredLoadAs !== undefined ? ({ loadAs } as any) : undefined);\n if (token === implementation) return;\n\n if (loadAs === LoadAs.Singleton) {\n root.registerFunction(token, () => root.get(implementation as any), {\n loadAs: LoadAs.Singleton,\n } as any);\n } else {\n root.registerFunction(token, (scope: IContainer) => scope.get(implementation as any), {\n loadAs,\n param: [SCOPED_CONTAINER],\n } as any);\n }\n }\n}\n\n/** Create a persistent immutable real-IoC test composition builder. */\nexport function testIoc(...inputs: UseInput[]): TestIocBuilder {\n return TestIocBuilder.create(inputs);\n}\n","/**\n * Diagnostics are first-class: every error names the real token/method and\n * what was expected vs what happened, never only internal wrapper machinery.\n */\n\nexport class TestingError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/** Thrown at build() when the installed @noego/ioc lacks the decoration seam. */\nexport class MissingIocSeamError extends TestingError {\n constructor() {\n super(\n '@noego/testing requires an @noego/ioc version that provides ' +\n 'Container.setInstanceDecorator (>= 0.5.x with the instance-decoration seam). ' +\n 'Upgrade @noego/ioc.',\n );\n }\n}\n\n/** test.inspect() on a method that is not watched in this environment. */\nexport class UnwatchedInspectionError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Method \"${method}\" on ${token} is not watched in this environment. ` +\n 'Only watched methods are inspectable — install test.watch() or any ' +\n 'test.* behavior/expectation descriptor for it.',\n );\n }\n}\n\n/** A call arrived after a test.calls([...]) script was fully consumed. */\nexport class CallScriptExhaustedError extends TestingError {\n constructor(token: string, method: string, scriptLength: number, callIndex: number) {\n super(\n `Call #${callIndex} to ${token}.${method} exceeds its test.calls() script ` +\n `of ${scriptLength} ${scriptLength === 1 ? 'entry' : 'entries'}.`,\n );\n }\n}\n\n/** An exact expectation (once/times/never) was exceeded at call time. */\nexport class ExpectationOverflowError extends TestingError {\n constructor(token: string, method: string, expected: number, attempted: number) {\n super(\n expected === 0\n ? `${token}.${method} was expected never to be called, but it was invoked.`\n : `${token}.${method} was expected exactly ${expected} ` +\n `${expected === 1 ? 'call' : 'calls'}, but call #${attempted} arrived.`,\n );\n }\n}\n\n/** Aggregated under-count failures reported by env.verify(). */\nexport class VerificationError extends TestingError {\n constructor(failures: readonly { token: string; method: string; expected: number; actual: number }[]) {\n super(\n 'Exact method expectations were not satisfied:\\n' +\n failures\n .map(\n (f) =>\n ` - ${f.token}.${f.method}: expected exactly ${f.expected} ` +\n `${f.expected === 1 ? 'call' : 'calls'}, observed ${f.actual}`,\n )\n .join('\\n'),\n );\n }\n}\n\n/** .methods configured for a token whose resolved value has no such callable method. */\nexport class MethodNotCallableError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Cannot install a test.* descriptor on ${token}.${method}: the resolved ` +\n 'instance has no callable method with that name.',\n );\n }\n}\n\n/** .methods configured for a token that resolved to a non-object value. */\nexport class NonObjectMethodTargetError extends TestingError {\n constructor(token: string) {\n super(\n `.methods() is configured for ${token}, but that token resolved to a ` +\n 'non-object value. Method descriptors apply only to IoC-managed instances.',\n );\n }\n}\n\n/** A string configuration key could not be resolved to a known IoC token. */\nexport class UnknownTokenKeyError extends TestingError {\n constructor(key: string, space: string, known: readonly string[]) {\n super(\n `Unknown ${space} key \"${key}\" — it does not match any token known to this ` +\n 'builder. Pass the class/token itself via a Map, or include the ' +\n 'registration through .use(...). Known tokens: ' +\n (known.length ? known.join(', ') : '(none)'),\n );\n }\n}\n\n/** Invalid descriptor construction (e.g. test.times(-1)). */\nexport class InvalidDescriptorError extends TestingError {}\n\n/**\n * A name-keyed compatibility entry referred to a display name claimed by\n * two or more distinct tokens. Tokens are identities; names are labels —\n * pass the exact token in canonical tuple form instead (spec 04 §5).\n */\nexport class AmbiguousNameKeyError extends TestingError {\n constructor(name: string, space: string) {\n super(\n `.${space}() key \"${name}\" is ambiguous: multiple distinct tokens share that display name. ` +\n `Use the canonical tuple form with the exact token: .${space}([[TheToken, ...]]).`,\n );\n this.name = 'AmbiguousNameKeyError';\n }\n}\n\n\n/**\n * A .methods() class token never matched any constructed instance while a\n * DIFFERENT class with the same display name did construct — the configured\n * behavior silently did not apply. Usual cause: two module registries loaded\n * the same source file (e.g. a vitest test file's import vs a framework\n * harness's native import of the production graph); fix by routing the\n * harness's imports through the caller's registry (testApp:\n * `.importer((p) => import(p))`) or by passing the token the graph actually\n * uses.\n */\nexport class TokenIdentitySplitError extends TestingError {\n constructor(names: readonly string[]) {\n super(\n `token identity split: .methods() entr${names.length === 1 ? 'y' : 'ies'} for ` +\n `${names.map((name) => `\"${name}\"`).join(', ')} never matched a constructed instance, ` +\n `but a DIFFERENT class with the same name was constructed. Two module registries ` +\n `have loaded the same class file (test-file import vs harness graph import) — the ` +\n `configured behavior did not apply. Route the harness's imports through your ` +\n `registry (e.g. testApp .importer((p) => import(p))) or pass the exact token the graph uses.`,\n );\n this.name = 'TokenIdentitySplitError';\n }\n}\n","/**\n * Lowercase `test.*` descriptors — immutable frozen values.\n *\n * Descriptors carry NO mutable state (no cursors, no counters, no histories);\n * all mutable invocation state lives in the built environment, so one\n * descriptor value is safe to share across builders and repeated builds.\n */\n\nimport { InvalidDescriptorError } from './errors';\n\nexport const DESCRIPTOR = Symbol.for('noego:testing:descriptor');\n\n/** A raw custom method wrapper: (original) => replacement. NOT auto-watched. */\nexport type RawMethodWrapper = (\n original: (...args: any[]) => any,\n) => (...args: any[]) => any;\n\nexport interface ReturnsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'returns';\n readonly value: unknown;\n}\n\nexport interface ThrowsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'throws';\n readonly error: unknown;\n}\n\nexport interface OriginalDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'original';\n}\n\nexport interface CallsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'calls';\n readonly script: readonly BehaviorDescriptor[];\n}\n\nexport type BehaviorDescriptor =\n | ReturnsDescriptor\n | ThrowsDescriptor\n | OriginalDescriptor\n | CallsDescriptor;\n\nexport interface WatchDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'watch';\n readonly wrapper?: RawMethodWrapper;\n}\n\nexport interface ExpectationDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'expect';\n /** Exact required call count; 0 for never(). */\n readonly expected: number;\n /** Behavior used for allowed calls; undefined = original effective behavior. */\n readonly behavior?: BehaviorDescriptor;\n}\n\n/** Everything installable through .methods({...}). */\nexport type MethodDescriptor =\n | BehaviorDescriptor\n | WatchDescriptor\n | ExpectationDescriptor\n | RawMethodWrapper;\n\nexport function isDescriptor(value: unknown): value is Exclude<MethodDescriptor, RawMethodWrapper> {\n return typeof value === 'object' && value !== null && (value as any)[DESCRIPTOR] === true;\n}\n\nfunction frozen<T extends object>(value: T): T {\n return Object.freeze(value);\n}\n\nfunction assertBehavior(value: unknown, where: string): asserts value is BehaviorDescriptor {\n if (!isDescriptor(value) || !['returns', 'throws', 'original', 'calls'].includes((value as any).kind)) {\n throw new InvalidDescriptorError(\n `${where} requires a behavior descriptor (test.returns/throws/original/calls).`,\n );\n }\n}\n\nexport const test = {\n /** Return the supplied value when the method is called. Auto-watches. */\n returns(value: unknown): ReturnsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'returns' as const, value });\n },\n\n /** Throw/reject with the supplied error. Auto-watches. */\n throws(error: unknown): ThrowsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'throws' as const, error });\n },\n\n /** Invoke the original effective method. Auto-watches. */\n original(): OriginalDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'original' as const });\n },\n\n /**\n * Per-invocation behavior script: call 1 uses entry 1, and so on. A call\n * after exhaustion fails immediately. Unused entries do not fail verification.\n */\n calls(script: readonly BehaviorDescriptor[]): CallsDescriptor {\n if (!Array.isArray(script)) {\n throw new InvalidDescriptorError('test.calls() requires an array of behavior descriptors.');\n }\n script.forEach((entry, i) => assertBehavior(entry, `test.calls() entry #${i + 1}`));\n return frozen({ [DESCRIPTOR]: true as const, kind: 'calls' as const, script: Object.freeze([...script]) });\n },\n\n /**\n * Keep original behavior and record calls. With a raw wrapper argument, the\n * wrapper's behavior runs and is recorded.\n */\n watch(wrapper?: RawMethodWrapper): WatchDescriptor {\n if (wrapper !== undefined && typeof wrapper !== 'function') {\n throw new InvalidDescriptorError('test.watch() accepts only a raw wrapper function.');\n }\n return frozen({ [DESCRIPTOR]: true as const, kind: 'watch' as const, wrapper });\n },\n\n /** Require exactly one call; with no behavior, the original runs. */\n once(behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (behavior !== undefined) assertBehavior(behavior, 'test.once()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 1, behavior });\n },\n\n /** Require exactly `count` calls; with no behavior, the original runs. */\n times(count: number, behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (!Number.isInteger(count) || count < 0) {\n throw new InvalidDescriptorError(\n `test.times() requires a non-negative integer count, received ${String(count)}.`,\n );\n }\n if (behavior !== undefined) assertBehavior(behavior, 'test.times()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: count, behavior });\n },\n\n /** Require zero calls; the first invocation fails and skips the original. */\n never(): ExpectationDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 0 });\n },\n\n /** Read the recorded history for a watched method in one environment. */\n inspect(environment: unknown, token: unknown, method: string): MethodInspection {\n const registry = (environment as any)?.[ENV_REGISTRY];\n if (!registry) {\n throw new InvalidDescriptorError(\n 'test.inspect() requires a built @noego/testing environment as its first argument.',\n );\n }\n return registry.inspect(token, method);\n },\n};\n\nObject.freeze(test);\n\n/** Symbol under which a built environment exposes its watch registry. */\nexport const ENV_REGISTRY = Symbol.for('noego:testing:env-registry');\n\nexport interface RecordedCall {\n /** 1-based invocation index in this environment. */\n readonly index: number;\n readonly args: readonly unknown[];\n /** Present once the call returned (resolved value for async methods). */\n readonly result?: unknown;\n /** Present once the call threw/rejected. */\n readonly error?: unknown;\n /** True while an async outcome is still pending. */\n readonly pending: boolean;\n readonly timestamp: number;\n}\n\nexport interface MethodInspection {\n readonly count: number;\n readonly calls: readonly RecordedCall[];\n}\n","/**\n * Environment-owned method behavior/observation runtime.\n *\n * All mutable state (histories, expectation counters, calls-script cursors)\n * lives here, created fresh at every build(). Descriptors stay immutable.\n */\n\nimport {\n type BehaviorDescriptor,\n type ExpectationDescriptor,\n type MethodDescriptor,\n type MethodInspection,\n type RawMethodWrapper,\n type RecordedCall,\n isDescriptor,\n} from './descriptors';\nimport {\n CallScriptExhaustedError,\n TokenIdentitySplitError,\n ExpectationOverflowError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnwatchedInspectionError,\n VerificationError,\n} from './errors';\n\nconst CONTEXT_WRAPPED = Symbol.for('ioc:context-wrapped');\nconst CONTEXT_OWNER = Symbol.for('ioc:context-owner');\n\nexport function tokenLabel(token: unknown): string {\n if (typeof token === 'function') return (token as { name?: string }).name || '[anonymous class]';\n if (typeof token === 'symbol') return String(token);\n return String(token);\n}\n\ninterface MutableCall {\n index: number;\n args: readonly unknown[];\n result?: unknown;\n error?: unknown;\n pending: boolean;\n timestamp: number;\n}\n\nexport class MethodState {\n readonly calls: MutableCall[] = [];\n /** Actual invocation count (includes the call currently executing). */\n actual = 0;\n /** Cursor into a test.calls() script. */\n scriptCursor = 0;\n\n constructor(\n readonly tokenName: string,\n readonly method: string,\n readonly descriptor: Exclude<MethodDescriptor, RawMethodWrapper>,\n ) {}\n\n get expectation(): ExpectationDescriptor | undefined {\n return this.descriptor.kind === 'expect' ? this.descriptor : undefined;\n }\n\n inspection(): MethodInspection {\n return {\n count: this.calls.length,\n calls: this.calls.map((c) => ({ ...c, args: [...c.args] }) as RecordedCall),\n };\n }\n}\n\n/** One method-config entry: how it was keyed, and its per-method descriptors. */\nexport interface MethodConfigEntry {\n /** Exact token (class/symbol/string) or a name string matched lazily. */\n readonly key: unknown;\n readonly byName: boolean;\n readonly methods: ReadonlyMap<string, MethodDescriptor>;\n}\n\nexport class WatchRegistry {\n /** entry-identity → method → state. Entries share states across instances. */\n private readonly states = new Map<unknown, Map<string, MethodState>>();\n private readonly nameIndex = new Map<string, unknown>();\n private readonly entries: MethodConfigEntry[] = [];\n /** Class-token entries that identity-matched at least one construction. */\n private readonly matchedEntryKeys = new Set<unknown>();\n /** Constructed class tokens that matched NO entry, by display name. */\n private readonly unmatchedConstructedByName = new Map<string, unknown>();\n\n addEntry(entry: MethodConfigEntry): void {\n this.entries.push(entry);\n const byMethod = new Map<string, MethodState>();\n for (const [method, descriptor] of entry.methods) {\n if (typeof descriptor === 'function') continue; // raw wrapper: unwatched, no state\n byMethod.set(method, new MethodState(this.entryLabel(entry), method, descriptor));\n }\n this.states.set(entry.key, byMethod);\n if (entry.byName) this.nameIndex.set(entry.key as string, entry.key);\n else if (typeof entry.key === 'function' && (entry.key as any).name) {\n this.nameIndex.set((entry.key as any).name, entry.key);\n }\n }\n\n private entryLabel(entry: MethodConfigEntry): string {\n return entry.byName ? String(entry.key) : tokenLabel(entry.key);\n }\n\n /** Entries applying to a resolving token (exact identity or name match). */\n matchEntries(token: unknown): MethodConfigEntry[] {\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n const matched = this.entries.filter(\n (entry) => entry.key === token || (entry.byName && name !== undefined && entry.key === name),\n );\n // Split-registry tripwire bookkeeping (spec 04 §17 \"duplicate\n // human-readable token names without identity collision\"): remember which\n // class-token entries genuinely bound, and which constructions bound\n // nothing — verify() cross-references the two by display name.\n if (matched.length) {\n for (const entry of matched) this.matchedEntryKeys.add(entry.key);\n } else if (typeof token === 'function' && name) {\n this.unmatchedConstructedByName.set(name, token);\n }\n return matched;\n }\n\n state(entryKey: unknown, method: string): MethodState | undefined {\n return this.states.get(entryKey)?.get(method);\n }\n\n inspect(token: unknown, method: string): MethodInspection {\n const label = tokenLabel(token);\n const keys: unknown[] = [token];\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n if (name !== undefined && this.nameIndex.has(name)) keys.push(this.nameIndex.get(name));\n for (const key of keys) {\n const state = this.states.get(key)?.get(method);\n if (state) return state.inspection();\n }\n throw new UnwatchedInspectionError(label, method);\n }\n\n /**\n * Class-token entries that never identity-matched a construction while a\n * DIFFERENT class with the same display name did construct. This is the\n * split-module-registry signature (a test-file class object vs the graph's\n * own load of the same file) — or two genuinely distinct same-named tokens\n * where the configured one never resolved. Either way the configured\n * behavior silently did not apply, which must be loud.\n */\n private identitySplits(): { name: string; entryToken: unknown }[] {\n const splits: { name: string; entryToken: unknown }[] = [];\n for (const entry of this.entries) {\n if (entry.byName || typeof entry.key !== 'function') continue;\n if (this.matchedEntryKeys.has(entry.key)) continue;\n const name = (entry.key as { name?: string }).name;\n if (!name) continue;\n const constructed = this.unmatchedConstructedByName.get(name);\n if (constructed !== undefined && constructed !== entry.key) {\n splits.push({ name, entryToken: entry.key });\n }\n }\n return splits;\n }\n\n /** Repeatable snapshot check of all exact expectations. */\n verify(): void {\n const splits = this.identitySplits();\n if (splits.length) {\n throw new TokenIdentitySplitError(splits.map((split) => split.name));\n }\n const failures: { token: string; method: string; expected: number; actual: number }[] = [];\n for (const byMethod of this.states.values()) {\n for (const state of byMethod.values()) {\n const expectation = state.expectation;\n if (!expectation) continue;\n if (state.actual !== expectation.expected) {\n failures.push({\n token: state.tokenName,\n method: state.method,\n expected: expectation.expected,\n actual: state.actual,\n });\n }\n }\n }\n if (failures.length) throw new VerificationError(failures);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as any).then === 'function';\n}\n\nfunction recordOutcome(call: MutableCall, outcome: unknown, threw: boolean): unknown {\n if (!threw && isPromiseLike(outcome)) {\n call.pending = true;\n outcome.then(\n (value) => {\n call.result = value;\n call.pending = false;\n },\n (error) => {\n call.error = error;\n call.pending = false;\n },\n );\n return outcome;\n }\n call.pending = false;\n if (threw) call.error = outcome;\n else call.result = outcome;\n return outcome;\n}\n\n/**\n * Build the ioc instance decorator for one environment.\n *\n * Identity-stable (WeakMap), preserves sync/async call shape and `this`\n * binding, forwards the ioc context symbols by delegating to the underlying\n * (context-wrapped) target for everything unconfigured.\n */\nexport function createMethodDecorator(registry: WatchRegistry): (instance: any, token: any) => any {\n const wrappers = new WeakMap<object, any>();\n\n return function decorate(instance: any, token: any): any {\n const entries = registry.matchEntries(token);\n if (entries.length === 0) return instance;\n\n if (instance === null || (typeof instance !== 'object' && typeof instance !== 'function')) {\n throw new NonObjectMethodTargetError(tokenLabel(token));\n }\n\n if (wrappers.has(instance)) return wrappers.get(instance);\n\n // Effective per-method config: entries merge in write order, LWW per method\n const effective = new Map<string, { entryKey: unknown; descriptor: MethodDescriptor }>();\n for (const entry of entries) {\n for (const [method, descriptor] of entry.methods) {\n effective.set(method, { entryKey: entry.key, descriptor });\n }\n }\n\n // Validate configured methods exist and are callable\n for (const method of effective.keys()) {\n if (typeof instance[method] !== 'function') {\n throw new MethodNotCallableError(tokenLabel(token), method);\n }\n }\n\n const methodCache = new Map<string, (...args: any[]) => any>();\n\n const proxy = new Proxy(instance, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && effective.has(prop)) {\n let wrapped = methodCache.get(prop);\n if (!wrapped) {\n const { entryKey, descriptor } = effective.get(prop)!;\n wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));\n methodCache.set(prop, wrapped);\n }\n return wrapped;\n }\n // Everything else (including ioc context symbols) delegates to the\n // underlying — usually context-wrapped — target.\n if (prop === CONTEXT_WRAPPED || prop === CONTEXT_OWNER) return (target as any)[prop];\n return Reflect.get(target, prop, receiver);\n },\n });\n\n wrappers.set(instance, proxy);\n return proxy;\n };\n}\n\nfunction buildMethodWrapper(\n target: any,\n method: string,\n descriptor: MethodDescriptor,\n state: MethodState | undefined,\n): (...args: any[]) => any {\n // The original effective method, read through the underlying target so the\n // ioc context proxy still owns context entry for real invocations.\n const callOriginal = (self: any, args: any[]) => {\n const fn = target[method];\n return fn.apply(self === undefined ? target : self, args);\n };\n\n // Raw custom wrapper: installed as-is, NOT watched, no recording.\n if (typeof descriptor === 'function') {\n const replacement = descriptor((...args: any[]) => callOriginal(target, args));\n return function (this: any, ...args: any[]) {\n return replacement.apply(this, args);\n };\n }\n\n if (!isDescriptor(descriptor)) {\n // Should be unreachable: builder validates descriptors on write.\n throw new TypeError(`Invalid method descriptor for ${method}`);\n }\n\n return function (this: any, ...args: any[]) {\n if (!state) throw new TypeError(`Missing method state for ${method}`);\n\n const expectation = state.expectation;\n const attempted = state.actual + 1;\n\n // Overflow fails immediately and never runs behavior/original\n if (expectation && attempted > expectation.expected) {\n state.actual = attempted;\n throw new ExpectationOverflowError(state.tokenName, method, expectation.expected, attempted);\n }\n\n state.actual = attempted;\n const call: MutableCall = {\n index: attempted,\n args: [...args],\n pending: false,\n timestamp: Date.now(),\n };\n state.calls.push(call);\n\n // Effective behavior for this invocation\n let behavior: BehaviorDescriptor | 'original-effective' | RawMethodWrapper;\n const base =\n descriptor.kind === 'expect'\n ? (descriptor.behavior ?? 'original-effective')\n : descriptor.kind === 'watch'\n ? (descriptor.wrapper ?? 'original-effective')\n : descriptor;\n\n if (base !== 'original-effective' && typeof base !== 'function' && base !== undefined && base.kind === 'calls') {\n if (state.scriptCursor >= base.script.length) {\n throw new CallScriptExhaustedError(state.tokenName, method, base.script.length, attempted);\n }\n behavior = base.script[state.scriptCursor]!;\n state.scriptCursor += 1;\n } else {\n behavior = base;\n }\n\n try {\n let outcome: unknown;\n if (behavior === 'original-effective') {\n outcome = callOriginal(this, args);\n } else if (typeof behavior === 'function') {\n // test.watch(rawWrapper): wrapper behavior runs and is recorded\n outcome = behavior((...inner: any[]) => callOriginal(this, inner)).apply(this, args);\n } else if (behavior.kind === 'returns') {\n outcome = behavior.value;\n } else if (behavior.kind === 'throws') {\n throw behavior.error;\n } else if (behavior.kind === 'original') {\n outcome = callOriginal(this, args);\n } else {\n throw new TypeError(`Nested test.calls() scripts are not supported (${method}).`);\n }\n return recordOutcome(call, outcome, false);\n } catch (error) {\n recordOutcome(call, error, true);\n throw error;\n }\n };\n}\n","/**\n * `installSeams` — apply the canonical substitution language (classes /\n * values / methods, exact tokens, `test.*` descriptors) to an EXISTING\n * container instead of a fresh `testIoc()` root.\n *\n * This is the seam surface for composed harnesses (application slices,\n * backend harnesses) that own their container construction but must speak\n * the same substitution language as every other tier: one vocabulary, one\n * verify contract, no harness-specific stubbing options.\n *\n * The returned handle carries the same watch registry marker as a\n * `TestEnvironment`, so `test.inspect(handle, Token, 'method')` works\n * unchanged.\n */\nimport { LoadAs, SCOPED_CONTAINER, type IContainer } from '@noego/ioc';\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError } from './errors';\nimport type { ConfigMap, MethodsConfig } from './builder';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\nexport interface SeamsConfig {\n classes?: ConfigMap<ClassLike>;\n values?: ConfigMap<unknown>;\n methods?: MethodsConfig;\n}\n\nexport interface InstalledSeams {\n /** Finalize call-count expectations (same semantics as env.verify()). */\n verify(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction* tupleEntries<V>(config: ConfigMap<V>, space: string): Iterable<[Token, V]> {\n if (Array.isArray(config)) {\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n `canonical ${space} entries are [token, value] tuples, e.g. .${space}([[Token, Impl]])`,\n );\n }\n yield [entry[0], entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, value];\n } else {\n throw new InvalidDescriptorError(\n `installSeams accepts only exact-token ${space} entries (tuple array or Map); ` +\n 'name-keyed records need the composition knowledge only testIoc() has.',\n );\n }\n}\n\n/**\n * Register a class replacement honoring the replacement's own @Component\n * scope, falling back to the token class's declared scope — a plain stub\n * replacing a Singleton-scoped production service must not silently degrade\n * to Transient (mirrors TestIocBuilder.registerClassBinding).\n */\nfunction registerClassBinding(root: IContainer, token: Token, implementation: ClassLike): void {\n const loadAs = componentScope(implementation) ?? componentScope(token) ?? LoadAs.Singleton;\n (root as any).registerClass(implementation, { loadAs });\n if (token === implementation) return;\n if (loadAs === LoadAs.Singleton) {\n (root as any).registerFunction(token, () => (root as any).get(implementation), {\n loadAs: LoadAs.Singleton,\n });\n } else {\n (root as any).registerFunction(token, (scope: IContainer) => (scope as any).get(implementation), {\n loadAs,\n param: [SCOPED_CONTAINER],\n });\n }\n}\n\nexport function installSeams(root: IContainer, config: SeamsConfig): InstalledSeams {\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n\n for (const [token, implementation] of tupleEntries(config.classes ?? [], 'classes')) {\n registerClassBinding(root, token, implementation);\n }\n for (const [token, value] of tupleEntries(config.values ?? [], 'values')) {\n (root as any).registerFunction(token, () => value, { loadAs: LoadAs.Singleton });\n }\n\n const registry = new WatchRegistry();\n for (const [token, methodsInput] of tupleEntries(config.methods ?? [], 'methods')) {\n const methods = new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods entry ${tokenLabel(token)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n registry.addEntry({ key: token, byName: false, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n return {\n verify: async () => registry.verify(),\n [ENV_REGISTRY]: registry,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,iBAOO;;;ACZA,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,cAAc;AACZ;AAAA,MACE;AAAA,IAGF;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAY,OAAe,QAAgB;AACzC;AAAA,MACE,WAAW,MAAM,QAAQ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