@noego/testing 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { IContainer, ApplicationModule } from '@noego/ioc';
1
+ import { IContainer, ApplicationModule, NormalizedRegistration } from '@noego/ioc';
2
2
 
3
3
  /**
4
4
  * Lowercase `test.*` descriptors — immutable frozen values.
@@ -210,6 +210,8 @@ interface BuildOptions {
210
210
  root?: IContainer;
211
211
  /** Compose production registrations on the fresh root before the seams. */
212
212
  prepare?: (root: IContainer) => void | Promise<void>;
213
+ /** Framework overlays may borrow caller-owned values without closing them. */
214
+ borrowedTokens?: readonly unknown[];
213
215
  }
214
216
  interface TestEnvironment {
215
217
  readonly root: IContainer;
@@ -249,6 +251,7 @@ declare class TestIocBuilder {
249
251
  * decorated. Instances `prepare` constructs itself are not decorated.
250
252
  */
251
253
  build(options?: BuildOptions): Promise<TestEnvironment>;
254
+ private buildOnRoot;
252
255
  /**
253
256
  * Register a class binding. When token === implementation this is a plain
254
257
  * class registration. Otherwise an alias factory resolves the implementation
@@ -357,4 +360,263 @@ interface InstalledSeams {
357
360
  }
358
361
  declare function installSeams(root: IContainer, config: SeamsConfig): InstalledSeams;
359
362
 
360
- export { AmbiguousNameKeyError, type BehaviorDescriptor, type BuildOptions, CallScriptExhaustedError, type CallsDescriptor, type ConfigMap, ENV_REGISTRY, type ExpectationDescriptor, ExpectationOverflowError, type InstalledSeams, InvalidDescriptorError, type MethodDescriptor, type MethodInspection, MethodNotCallableError, type MethodsConfig, MissingIocSeamError, NonObjectMethodTargetError, type OriginalDescriptor, type RawMethodWrapper, type RecordedCall, type ReturnsDescriptor, type SeamsConfig, type TestEnvironment, TestIocBuilder, TestingError, type ThrowsDescriptor, TokenIdentitySplitError, UnknownTokenKeyError, UnwatchedInspectionError, type UseInput, VerificationError, type WatchDescriptor, installSeams, test, testIoc };
363
+ type TestOwner = 'server' | 'client' | 'main' | 'renderer';
364
+ interface ReplacementOptions {
365
+ readonly owner?: TestOwner;
366
+ }
367
+ interface LoaderReference {
368
+ readonly path: string;
369
+ readonly export: string;
370
+ }
371
+ type LoaderIdentity = string | LoaderReference;
372
+ type ClassToken<T = any> = abstract new (...args: any[]) => T;
373
+ type ReplacementClass<T = any> = new (...args: any[]) => T;
374
+ type ReplacementFunction = (...args: any[]) => any;
375
+ type ExecutableReplacement = ReplacementFunction | MethodDescriptor;
376
+ interface EntryBase {
377
+ readonly owner?: TestOwner;
378
+ /** Fluent entry index, prefixed by each enclosing .use entry index. */
379
+ readonly provenance: readonly number[];
380
+ }
381
+ type StubEntry = EntryBase & ({
382
+ readonly kind: 'class';
383
+ readonly target: unknown;
384
+ readonly replacement: ReplacementClass;
385
+ } | {
386
+ readonly kind: 'function';
387
+ readonly target: unknown;
388
+ readonly replacement: ReplacementFunction;
389
+ } | {
390
+ readonly kind: 'value';
391
+ readonly target: unknown;
392
+ readonly replacement: unknown;
393
+ } | {
394
+ readonly kind: 'method';
395
+ readonly target: unknown;
396
+ readonly method: string;
397
+ readonly replacement: MethodDescriptor;
398
+ } | {
399
+ readonly kind: 'middleware';
400
+ readonly target: string;
401
+ readonly replacement: ExecutableReplacement;
402
+ } | {
403
+ readonly kind: 'load';
404
+ readonly target: LoaderReference;
405
+ readonly replacement: ExecutableReplacement;
406
+ });
407
+ /** Immutable replacement description only; no container, resources or call history. */
408
+ declare class TestStub {
409
+ private constructor();
410
+ class<T>(target: ClassToken<T>, replacement: ReplacementClass<T>, options?: ReplacementOptions): TestStub;
411
+ function(target: unknown, replacement: ReplacementFunction, options?: ReplacementOptions): TestStub;
412
+ method(target: unknown, method: string, replacement: MethodDescriptor, options?: ReplacementOptions): TestStub;
413
+ value(target: unknown, replacement: unknown, options?: ReplacementOptions): TestStub;
414
+ middleware(target: string, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub;
415
+ load(target: LoaderIdentity, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub;
416
+ use(other: TestStub): TestStub;
417
+ }
418
+ declare function testStub(): TestStub;
419
+ /** Framework adapter input. Entries are descriptions, not resolved replacements. */
420
+ declare function stubEntries(stub: TestStub): readonly StubEntry[];
421
+
422
+ /** Shared source selection. Never parses source or constructs a runtime graph. */
423
+ type OwnerSelection = {
424
+ readonly module: string | readonly string[];
425
+ readonly path?: never;
426
+ } | {
427
+ readonly path: readonly string[];
428
+ readonly module?: never;
429
+ } | {
430
+ readonly module?: never;
431
+ readonly path?: never;
432
+ };
433
+ interface SourceSelectionEntry {
434
+ readonly path: string;
435
+ readonly module?: string | null;
436
+ }
437
+ interface SourceSelectionOptions {
438
+ readonly owner?: string;
439
+ readonly native?: boolean;
440
+ /** Declared modules including empty modules, supplied by the production collector. */
441
+ readonly modules?: readonly string[];
442
+ }
443
+ declare class SourceSelectionError extends Error {
444
+ readonly owner?: string | undefined;
445
+ readonly choices: readonly string[];
446
+ readonly code = "testing/selection";
447
+ constructor(message: string, owner?: string | undefined, choices?: readonly string[]);
448
+ }
449
+ /** Undefined means all declared owners; an explicit empty outer object is an error. */
450
+ declare function normalizeTestSelection(selection: unknown, declaredOwners: readonly string[]): Readonly<Record<string, OwnerSelection>>;
451
+ /** Retains source order and every declared operation at each selected source path. */
452
+ declare function selectSourceEntries<T extends SourceSelectionEntry>(source: readonly T[], input: OwnerSelection, options?: SourceSelectionOptions): T[];
453
+
454
+ interface TestResource {
455
+ dispose(): unknown | Promise<unknown>;
456
+ }
457
+ interface VerifiableTestResource extends TestResource {
458
+ verify(): unknown | Promise<unknown>;
459
+ /** Finish/cancel framework-owned finite work before checking expectations. */
460
+ settle?(): unknown | Promise<unknown>;
461
+ }
462
+ interface FinalizationFailure {
463
+ readonly owner: string;
464
+ readonly phase: 'test' | 'settle' | 'verify' | 'dispose';
465
+ readonly error: unknown;
466
+ }
467
+ declare class TestFinalizationError extends AggregateError {
468
+ readonly failures: readonly FinalizationFailure[];
469
+ constructor(failures: readonly FinalizationFailure[]);
470
+ }
471
+ /**
472
+ * Register immediately after acquisition; acquire dependencies before borrowers.
473
+ * Each test/retry owns a new scope. Resources shared inside one restart test are
474
+ * registered once, and disposed after that test's application borrowers.
475
+ */
476
+ declare class TestResourceScope implements TestResource {
477
+ private readonly resources;
478
+ private readonly owned;
479
+ private closing;
480
+ private complete;
481
+ /** Runner finalizers can avoid reporting an already-finished failure twice. */
482
+ get finalized(): boolean;
483
+ own<T extends TestResource>(resource: T, owner?: string): T;
484
+ environment<T extends VerifiableTestResource>(resource: T, owner?: string): T;
485
+ dispose(): Promise<void>;
486
+ }
487
+ declare function createTestScope(): TestResourceScope;
488
+ /** Optional runner-neutral boundary; runner adapters can own the same scope directly. */
489
+ declare function withTestScope<T>(body: (scope: TestResourceScope) => T | Promise<T>): Promise<T>;
490
+
491
+ /**
492
+ * Thin runner adapter for test functions (Vitest 2/3/4, Node test and Jest).
493
+ * The runner still owns test discovery, assertions, retries and timeout reporting.
494
+ * Every invocation/retry gets a new scope; framework builds register themselves
495
+ * under async-capable Node runtimes. Browsers use the explicit scope argument.
496
+ */
497
+ declare function resourceCase<Args extends unknown[], Result>(body: (resources: TestResourceScope, ...args: Args) => Result | Promise<Result>): (...args: Args) => Promise<Result>;
498
+
499
+ /** Runner configuration/report checks only: these functions never fabricate coverage or test counters. */
500
+ declare const COVERAGE_METRICS: readonly ["lines", "statements", "functions", "branches"];
501
+ type CoverageMetric = typeof COVERAGE_METRICS[number];
502
+ type CoverageThresholds = Record<CoverageMetric, number>;
503
+ interface CoverageExclusion {
504
+ pattern: string;
505
+ kind: 'tests' | 'types' | 'generated' | 'nonexecutable' | 'separate-runtime';
506
+ reason: string;
507
+ /** Generated or separately qualified runtime code needs a concrete evidence reference. */
508
+ evidence?: string;
509
+ }
510
+ interface VitestCoverageInput {
511
+ runnerVersion: string;
512
+ providerVersion: string;
513
+ include: readonly string[];
514
+ exclusions?: readonly CoverageExclusion[];
515
+ thresholds?: Partial<CoverageThresholds>;
516
+ }
517
+ declare class TestCoverageConfigurationError extends Error {
518
+ constructor(message: string);
519
+ }
520
+ /** V8 preset with explicit uncovered-source inclusion and reviewable exclusion provenance. */
521
+ declare function vitestCoverage(input: VitestCoverageInput): {
522
+ options: {
523
+ reporter: Array<"text-summary" | "json-summary" | "json">;
524
+ reportOnFailure: boolean;
525
+ thresholds: {
526
+ functions: number;
527
+ lines: number;
528
+ statements: number;
529
+ branches: number;
530
+ };
531
+ all?: boolean | undefined;
532
+ provider: "v8";
533
+ include: any[];
534
+ exclude: string[];
535
+ };
536
+ provenance: Readonly<{
537
+ runner: "vitest";
538
+ runnerVersion: string;
539
+ provider: "@vitest/coverage-v8";
540
+ providerVersion: string;
541
+ includesUnimported: true;
542
+ include: readonly any[];
543
+ exclusions: readonly Readonly<{
544
+ pattern: string;
545
+ kind: "tests" | "types" | "generated" | "nonexecutable" | "separate-runtime";
546
+ reason: string;
547
+ /** Generated or separately qualified runtime code needs a concrete evidence reference. */
548
+ evidence?: string;
549
+ }>[];
550
+ thresholds: Readonly<CoverageThresholds>;
551
+ metrics: readonly ("functions" | "lines" | "statements" | "branches")[];
552
+ }>;
553
+ };
554
+ interface TestLaneReport {
555
+ name: string;
556
+ total: number;
557
+ passed: number;
558
+ failed: number;
559
+ skipped: number;
560
+ }
561
+ declare class TestDiscoveryError extends Error {
562
+ readonly failures: readonly string[];
563
+ constructor(failures: readonly string[]);
564
+ }
565
+ /** Validate counts taken from native runner reports; this is not a test discovery implementation. */
566
+ declare function assertTestLanes(required: readonly string[], reports: readonly TestLaneReport[]): void;
567
+
568
+ /** No synchronous global-current fallback: browser callers retain explicit scope.own(). */
569
+ declare function runInResourceScope<T>(scope: TestResourceScope, body: () => T): T;
570
+ /** Called by framework build terminals; failed/late admission closes the new resource. */
571
+ declare function registerTestResource<T extends TestResource>(resource: T, owner?: string): Promise<T>;
572
+
573
+ /** Supplied by framework production discovery, never by a product-local route map. */
574
+ interface TestOwnerCatalog {
575
+ readonly owner: TestOwner;
576
+ readonly bindings: readonly NormalizedRegistration[];
577
+ readonly middleware?: readonly string[];
578
+ readonly loaders?: readonly LoaderReference[];
579
+ }
580
+ interface ResolvedTestOverlay {
581
+ readonly owner: TestOwner;
582
+ readonly entry: StubEntry;
583
+ readonly binding?: NormalizedRegistration;
584
+ }
585
+ declare class TestOverlayError extends Error {
586
+ readonly entry: StubEntry;
587
+ readonly code = "testing/overlay";
588
+ constructor(message: string, entry: StubEntry);
589
+ }
590
+ /**
591
+ * Validate EVERY entry before reducing last-write-wins slots. Resolve identities
592
+ * exactly, never by class display name; method seams remain independent of the
593
+ * final binding slot and are installed after all binding replacements.
594
+ */
595
+ declare function resolveTestOverlays(stub: TestStub, catalogs: readonly TestOwnerCatalog[]): readonly ResolvedTestOverlay[];
596
+
597
+ interface TestBindingPlan {
598
+ readonly builder: TestIocBuilder;
599
+ /** Pass to builder.build alongside the framework's unresolved root. */
600
+ readonly buildOptions: Pick<BuildOptions, 'borrowedTokens'>;
601
+ }
602
+ /** Apply resolved binding entries to the existing real-IoC description. No new root. */
603
+ declare function applyTestBindings(production: TestIocBuilder, overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestBindingPlan;
604
+
605
+ type TestExecutableKind = 'middleware' | 'load';
606
+ interface TestExecutableOverlays {
607
+ replace(kind: TestExecutableKind, target: string | LoaderReference, original: ReplacementFunction): ReplacementFunction;
608
+ inspect(kind: TestExecutableKind, target: string | LoaderReference): MethodInspection;
609
+ verify(): Promise<void>;
610
+ readonly [ENV_REGISTRY]: WatchRegistry;
611
+ }
612
+ /** Per-environment executable seams; uses the same test.* runtime as IoC methods. */
613
+ declare function createTestExecutables(overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestExecutableOverlays;
614
+
615
+ /**
616
+ * Framework discovery over registration descriptions and compiler-discovered
617
+ * classes. Implicit injectable class dependencies are included without resolving
618
+ * a container or matching a replacement by its display name.
619
+ */
620
+ declare function describeTestBindings(builder: TestIocBuilder, discovered?: readonly unknown[]): readonly NormalizedRegistration[];
621
+
622
+ export { AmbiguousNameKeyError, type BehaviorDescriptor, type BuildOptions, COVERAGE_METRICS, CallScriptExhaustedError, type CallsDescriptor, type ClassToken, type ConfigMap, type CoverageExclusion, type CoverageMetric, type CoverageThresholds, ENV_REGISTRY, type ExecutableReplacement, type ExpectationDescriptor, ExpectationOverflowError, type FinalizationFailure, type InstalledSeams, InvalidDescriptorError, type LoaderIdentity, type LoaderReference, type MethodDescriptor, type MethodInspection, MethodNotCallableError, type MethodsConfig, MissingIocSeamError, NonObjectMethodTargetError, type OriginalDescriptor, type OwnerSelection, type RawMethodWrapper, type RecordedCall, type ReplacementClass, type ReplacementFunction, type ReplacementOptions, type ResolvedTestOverlay, type ReturnsDescriptor, type SeamsConfig, type SourceSelectionEntry, SourceSelectionError, type SourceSelectionOptions, type StubEntry, type TestBindingPlan, TestCoverageConfigurationError, TestDiscoveryError, type TestEnvironment, type TestExecutableKind, type TestExecutableOverlays, TestFinalizationError, TestIocBuilder, type TestLaneReport, TestOverlayError, type TestOwner, type TestOwnerCatalog, type TestResource, TestResourceScope, TestStub, TestingError, type ThrowsDescriptor, TokenIdentitySplitError, UnknownTokenKeyError, UnwatchedInspectionError, type UseInput, type VerifiableTestResource, VerificationError, type VitestCoverageInput, type WatchDescriptor, applyTestBindings, assertTestLanes, createTestExecutables, createTestScope, describeTestBindings, installSeams, normalizeTestSelection, registerTestResource, resolveTestOverlays, resourceCase, runInResourceScope, selectSourceEntries, stubEntries, test, testIoc, testStub, vitestCoverage, withTestScope };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IContainer, ApplicationModule } from '@noego/ioc';
1
+ import { IContainer, ApplicationModule, NormalizedRegistration } from '@noego/ioc';
2
2
 
3
3
  /**
4
4
  * Lowercase `test.*` descriptors — immutable frozen values.
@@ -210,6 +210,8 @@ interface BuildOptions {
210
210
  root?: IContainer;
211
211
  /** Compose production registrations on the fresh root before the seams. */
212
212
  prepare?: (root: IContainer) => void | Promise<void>;
213
+ /** Framework overlays may borrow caller-owned values without closing them. */
214
+ borrowedTokens?: readonly unknown[];
213
215
  }
214
216
  interface TestEnvironment {
215
217
  readonly root: IContainer;
@@ -249,6 +251,7 @@ declare class TestIocBuilder {
249
251
  * decorated. Instances `prepare` constructs itself are not decorated.
250
252
  */
251
253
  build(options?: BuildOptions): Promise<TestEnvironment>;
254
+ private buildOnRoot;
252
255
  /**
253
256
  * Register a class binding. When token === implementation this is a plain
254
257
  * class registration. Otherwise an alias factory resolves the implementation
@@ -357,4 +360,263 @@ interface InstalledSeams {
357
360
  }
358
361
  declare function installSeams(root: IContainer, config: SeamsConfig): InstalledSeams;
359
362
 
360
- export { AmbiguousNameKeyError, type BehaviorDescriptor, type BuildOptions, CallScriptExhaustedError, type CallsDescriptor, type ConfigMap, ENV_REGISTRY, type ExpectationDescriptor, ExpectationOverflowError, type InstalledSeams, InvalidDescriptorError, type MethodDescriptor, type MethodInspection, MethodNotCallableError, type MethodsConfig, MissingIocSeamError, NonObjectMethodTargetError, type OriginalDescriptor, type RawMethodWrapper, type RecordedCall, type ReturnsDescriptor, type SeamsConfig, type TestEnvironment, TestIocBuilder, TestingError, type ThrowsDescriptor, TokenIdentitySplitError, UnknownTokenKeyError, UnwatchedInspectionError, type UseInput, VerificationError, type WatchDescriptor, installSeams, test, testIoc };
363
+ type TestOwner = 'server' | 'client' | 'main' | 'renderer';
364
+ interface ReplacementOptions {
365
+ readonly owner?: TestOwner;
366
+ }
367
+ interface LoaderReference {
368
+ readonly path: string;
369
+ readonly export: string;
370
+ }
371
+ type LoaderIdentity = string | LoaderReference;
372
+ type ClassToken<T = any> = abstract new (...args: any[]) => T;
373
+ type ReplacementClass<T = any> = new (...args: any[]) => T;
374
+ type ReplacementFunction = (...args: any[]) => any;
375
+ type ExecutableReplacement = ReplacementFunction | MethodDescriptor;
376
+ interface EntryBase {
377
+ readonly owner?: TestOwner;
378
+ /** Fluent entry index, prefixed by each enclosing .use entry index. */
379
+ readonly provenance: readonly number[];
380
+ }
381
+ type StubEntry = EntryBase & ({
382
+ readonly kind: 'class';
383
+ readonly target: unknown;
384
+ readonly replacement: ReplacementClass;
385
+ } | {
386
+ readonly kind: 'function';
387
+ readonly target: unknown;
388
+ readonly replacement: ReplacementFunction;
389
+ } | {
390
+ readonly kind: 'value';
391
+ readonly target: unknown;
392
+ readonly replacement: unknown;
393
+ } | {
394
+ readonly kind: 'method';
395
+ readonly target: unknown;
396
+ readonly method: string;
397
+ readonly replacement: MethodDescriptor;
398
+ } | {
399
+ readonly kind: 'middleware';
400
+ readonly target: string;
401
+ readonly replacement: ExecutableReplacement;
402
+ } | {
403
+ readonly kind: 'load';
404
+ readonly target: LoaderReference;
405
+ readonly replacement: ExecutableReplacement;
406
+ });
407
+ /** Immutable replacement description only; no container, resources or call history. */
408
+ declare class TestStub {
409
+ private constructor();
410
+ class<T>(target: ClassToken<T>, replacement: ReplacementClass<T>, options?: ReplacementOptions): TestStub;
411
+ function(target: unknown, replacement: ReplacementFunction, options?: ReplacementOptions): TestStub;
412
+ method(target: unknown, method: string, replacement: MethodDescriptor, options?: ReplacementOptions): TestStub;
413
+ value(target: unknown, replacement: unknown, options?: ReplacementOptions): TestStub;
414
+ middleware(target: string, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub;
415
+ load(target: LoaderIdentity, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub;
416
+ use(other: TestStub): TestStub;
417
+ }
418
+ declare function testStub(): TestStub;
419
+ /** Framework adapter input. Entries are descriptions, not resolved replacements. */
420
+ declare function stubEntries(stub: TestStub): readonly StubEntry[];
421
+
422
+ /** Shared source selection. Never parses source or constructs a runtime graph. */
423
+ type OwnerSelection = {
424
+ readonly module: string | readonly string[];
425
+ readonly path?: never;
426
+ } | {
427
+ readonly path: readonly string[];
428
+ readonly module?: never;
429
+ } | {
430
+ readonly module?: never;
431
+ readonly path?: never;
432
+ };
433
+ interface SourceSelectionEntry {
434
+ readonly path: string;
435
+ readonly module?: string | null;
436
+ }
437
+ interface SourceSelectionOptions {
438
+ readonly owner?: string;
439
+ readonly native?: boolean;
440
+ /** Declared modules including empty modules, supplied by the production collector. */
441
+ readonly modules?: readonly string[];
442
+ }
443
+ declare class SourceSelectionError extends Error {
444
+ readonly owner?: string | undefined;
445
+ readonly choices: readonly string[];
446
+ readonly code = "testing/selection";
447
+ constructor(message: string, owner?: string | undefined, choices?: readonly string[]);
448
+ }
449
+ /** Undefined means all declared owners; an explicit empty outer object is an error. */
450
+ declare function normalizeTestSelection(selection: unknown, declaredOwners: readonly string[]): Readonly<Record<string, OwnerSelection>>;
451
+ /** Retains source order and every declared operation at each selected source path. */
452
+ declare function selectSourceEntries<T extends SourceSelectionEntry>(source: readonly T[], input: OwnerSelection, options?: SourceSelectionOptions): T[];
453
+
454
+ interface TestResource {
455
+ dispose(): unknown | Promise<unknown>;
456
+ }
457
+ interface VerifiableTestResource extends TestResource {
458
+ verify(): unknown | Promise<unknown>;
459
+ /** Finish/cancel framework-owned finite work before checking expectations. */
460
+ settle?(): unknown | Promise<unknown>;
461
+ }
462
+ interface FinalizationFailure {
463
+ readonly owner: string;
464
+ readonly phase: 'test' | 'settle' | 'verify' | 'dispose';
465
+ readonly error: unknown;
466
+ }
467
+ declare class TestFinalizationError extends AggregateError {
468
+ readonly failures: readonly FinalizationFailure[];
469
+ constructor(failures: readonly FinalizationFailure[]);
470
+ }
471
+ /**
472
+ * Register immediately after acquisition; acquire dependencies before borrowers.
473
+ * Each test/retry owns a new scope. Resources shared inside one restart test are
474
+ * registered once, and disposed after that test's application borrowers.
475
+ */
476
+ declare class TestResourceScope implements TestResource {
477
+ private readonly resources;
478
+ private readonly owned;
479
+ private closing;
480
+ private complete;
481
+ /** Runner finalizers can avoid reporting an already-finished failure twice. */
482
+ get finalized(): boolean;
483
+ own<T extends TestResource>(resource: T, owner?: string): T;
484
+ environment<T extends VerifiableTestResource>(resource: T, owner?: string): T;
485
+ dispose(): Promise<void>;
486
+ }
487
+ declare function createTestScope(): TestResourceScope;
488
+ /** Optional runner-neutral boundary; runner adapters can own the same scope directly. */
489
+ declare function withTestScope<T>(body: (scope: TestResourceScope) => T | Promise<T>): Promise<T>;
490
+
491
+ /**
492
+ * Thin runner adapter for test functions (Vitest 2/3/4, Node test and Jest).
493
+ * The runner still owns test discovery, assertions, retries and timeout reporting.
494
+ * Every invocation/retry gets a new scope; framework builds register themselves
495
+ * under async-capable Node runtimes. Browsers use the explicit scope argument.
496
+ */
497
+ declare function resourceCase<Args extends unknown[], Result>(body: (resources: TestResourceScope, ...args: Args) => Result | Promise<Result>): (...args: Args) => Promise<Result>;
498
+
499
+ /** Runner configuration/report checks only: these functions never fabricate coverage or test counters. */
500
+ declare const COVERAGE_METRICS: readonly ["lines", "statements", "functions", "branches"];
501
+ type CoverageMetric = typeof COVERAGE_METRICS[number];
502
+ type CoverageThresholds = Record<CoverageMetric, number>;
503
+ interface CoverageExclusion {
504
+ pattern: string;
505
+ kind: 'tests' | 'types' | 'generated' | 'nonexecutable' | 'separate-runtime';
506
+ reason: string;
507
+ /** Generated or separately qualified runtime code needs a concrete evidence reference. */
508
+ evidence?: string;
509
+ }
510
+ interface VitestCoverageInput {
511
+ runnerVersion: string;
512
+ providerVersion: string;
513
+ include: readonly string[];
514
+ exclusions?: readonly CoverageExclusion[];
515
+ thresholds?: Partial<CoverageThresholds>;
516
+ }
517
+ declare class TestCoverageConfigurationError extends Error {
518
+ constructor(message: string);
519
+ }
520
+ /** V8 preset with explicit uncovered-source inclusion and reviewable exclusion provenance. */
521
+ declare function vitestCoverage(input: VitestCoverageInput): {
522
+ options: {
523
+ reporter: Array<"text-summary" | "json-summary" | "json">;
524
+ reportOnFailure: boolean;
525
+ thresholds: {
526
+ functions: number;
527
+ lines: number;
528
+ statements: number;
529
+ branches: number;
530
+ };
531
+ all?: boolean | undefined;
532
+ provider: "v8";
533
+ include: any[];
534
+ exclude: string[];
535
+ };
536
+ provenance: Readonly<{
537
+ runner: "vitest";
538
+ runnerVersion: string;
539
+ provider: "@vitest/coverage-v8";
540
+ providerVersion: string;
541
+ includesUnimported: true;
542
+ include: readonly any[];
543
+ exclusions: readonly Readonly<{
544
+ pattern: string;
545
+ kind: "tests" | "types" | "generated" | "nonexecutable" | "separate-runtime";
546
+ reason: string;
547
+ /** Generated or separately qualified runtime code needs a concrete evidence reference. */
548
+ evidence?: string;
549
+ }>[];
550
+ thresholds: Readonly<CoverageThresholds>;
551
+ metrics: readonly ("functions" | "lines" | "statements" | "branches")[];
552
+ }>;
553
+ };
554
+ interface TestLaneReport {
555
+ name: string;
556
+ total: number;
557
+ passed: number;
558
+ failed: number;
559
+ skipped: number;
560
+ }
561
+ declare class TestDiscoveryError extends Error {
562
+ readonly failures: readonly string[];
563
+ constructor(failures: readonly string[]);
564
+ }
565
+ /** Validate counts taken from native runner reports; this is not a test discovery implementation. */
566
+ declare function assertTestLanes(required: readonly string[], reports: readonly TestLaneReport[]): void;
567
+
568
+ /** No synchronous global-current fallback: browser callers retain explicit scope.own(). */
569
+ declare function runInResourceScope<T>(scope: TestResourceScope, body: () => T): T;
570
+ /** Called by framework build terminals; failed/late admission closes the new resource. */
571
+ declare function registerTestResource<T extends TestResource>(resource: T, owner?: string): Promise<T>;
572
+
573
+ /** Supplied by framework production discovery, never by a product-local route map. */
574
+ interface TestOwnerCatalog {
575
+ readonly owner: TestOwner;
576
+ readonly bindings: readonly NormalizedRegistration[];
577
+ readonly middleware?: readonly string[];
578
+ readonly loaders?: readonly LoaderReference[];
579
+ }
580
+ interface ResolvedTestOverlay {
581
+ readonly owner: TestOwner;
582
+ readonly entry: StubEntry;
583
+ readonly binding?: NormalizedRegistration;
584
+ }
585
+ declare class TestOverlayError extends Error {
586
+ readonly entry: StubEntry;
587
+ readonly code = "testing/overlay";
588
+ constructor(message: string, entry: StubEntry);
589
+ }
590
+ /**
591
+ * Validate EVERY entry before reducing last-write-wins slots. Resolve identities
592
+ * exactly, never by class display name; method seams remain independent of the
593
+ * final binding slot and are installed after all binding replacements.
594
+ */
595
+ declare function resolveTestOverlays(stub: TestStub, catalogs: readonly TestOwnerCatalog[]): readonly ResolvedTestOverlay[];
596
+
597
+ interface TestBindingPlan {
598
+ readonly builder: TestIocBuilder;
599
+ /** Pass to builder.build alongside the framework's unresolved root. */
600
+ readonly buildOptions: Pick<BuildOptions, 'borrowedTokens'>;
601
+ }
602
+ /** Apply resolved binding entries to the existing real-IoC description. No new root. */
603
+ declare function applyTestBindings(production: TestIocBuilder, overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestBindingPlan;
604
+
605
+ type TestExecutableKind = 'middleware' | 'load';
606
+ interface TestExecutableOverlays {
607
+ replace(kind: TestExecutableKind, target: string | LoaderReference, original: ReplacementFunction): ReplacementFunction;
608
+ inspect(kind: TestExecutableKind, target: string | LoaderReference): MethodInspection;
609
+ verify(): Promise<void>;
610
+ readonly [ENV_REGISTRY]: WatchRegistry;
611
+ }
612
+ /** Per-environment executable seams; uses the same test.* runtime as IoC methods. */
613
+ declare function createTestExecutables(overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestExecutableOverlays;
614
+
615
+ /**
616
+ * Framework discovery over registration descriptions and compiler-discovered
617
+ * classes. Implicit injectable class dependencies are included without resolving
618
+ * a container or matching a replacement by its display name.
619
+ */
620
+ declare function describeTestBindings(builder: TestIocBuilder, discovered?: readonly unknown[]): readonly NormalizedRegistration[];
621
+
622
+ export { AmbiguousNameKeyError, type BehaviorDescriptor, type BuildOptions, COVERAGE_METRICS, CallScriptExhaustedError, type CallsDescriptor, type ClassToken, type ConfigMap, type CoverageExclusion, type CoverageMetric, type CoverageThresholds, ENV_REGISTRY, type ExecutableReplacement, type ExpectationDescriptor, ExpectationOverflowError, type FinalizationFailure, type InstalledSeams, InvalidDescriptorError, type LoaderIdentity, type LoaderReference, type MethodDescriptor, type MethodInspection, MethodNotCallableError, type MethodsConfig, MissingIocSeamError, NonObjectMethodTargetError, type OriginalDescriptor, type OwnerSelection, type RawMethodWrapper, type RecordedCall, type ReplacementClass, type ReplacementFunction, type ReplacementOptions, type ResolvedTestOverlay, type ReturnsDescriptor, type SeamsConfig, type SourceSelectionEntry, SourceSelectionError, type SourceSelectionOptions, type StubEntry, type TestBindingPlan, TestCoverageConfigurationError, TestDiscoveryError, type TestEnvironment, type TestExecutableKind, type TestExecutableOverlays, TestFinalizationError, TestIocBuilder, type TestLaneReport, TestOverlayError, type TestOwner, type TestOwnerCatalog, type TestResource, TestResourceScope, TestStub, TestingError, type ThrowsDescriptor, TokenIdentitySplitError, UnknownTokenKeyError, UnwatchedInspectionError, type UseInput, type VerifiableTestResource, VerificationError, type VitestCoverageInput, type WatchDescriptor, applyTestBindings, assertTestLanes, createTestExecutables, createTestScope, describeTestBindings, installSeams, normalizeTestSelection, registerTestResource, resolveTestOverlays, resourceCase, runInResourceScope, selectSourceEntries, stubEntries, test, testIoc, testStub, vitestCoverage, withTestScope };