@plyaz/types 1.5.2 → 1.5.3

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.
@@ -68,11 +68,8 @@ import type { UnknownRecord } from 'type-fest';
68
68
  * ```
69
69
  */
70
70
  export interface SubscriptionInfo<T = unknown> {
71
- /** Unique identifier for the subscription */
72
71
  id: string;
73
- /** Mocked callback function that receives subscription data */
74
72
  callback: Vitest.MockedFunction<(data: T) => void>;
75
- /** Function to unsubscribe from the event */
76
73
  unsubscribe: () => void;
77
74
  }
78
75
  /**
@@ -99,25 +96,15 @@ export interface SubscriptionInfo<T = unknown> {
99
96
  * ```
100
97
  */
101
98
  export interface SubscriptionTracker<T = unknown> {
102
- /** Track a new subscription with optional ID */
103
99
  track: (subscribeFn: (callback: (data: T) => void) => () => void, id?: string) => SubscriptionInfo<T>;
104
- /** Unsubscribe a specific subscription by ID */
105
100
  unsubscribe: (id: string) => void;
106
- /** Unsubscribe all tracked subscriptions */
107
101
  unsubscribeAll: () => void;
108
- /** Get the number of times a subscription callback was called */
109
102
  getCallCount: (id: string) => number;
110
- /** Get the data from the last callback invocation */
111
103
  getLastCall: (id: string) => T | null;
112
- /** Get all data from all callback invocations */
113
104
  getAllCalls: (id: string) => T[];
114
- /** Reset all subscriptions and their call history */
115
105
  reset: () => void;
116
- /** Reset only the callback history, keeping subscriptions active */
117
106
  resetCallbacks: () => void;
118
- /** Get list of active subscription IDs */
119
107
  getActiveSubscriptions: () => string[];
120
- /** Check if a subscription is currently active */
121
108
  hasSubscription: (id: string) => boolean;
122
109
  }
123
110
  /**
@@ -142,13 +129,9 @@ export interface SubscriptionTracker<T = unknown> {
142
129
  * ```
143
130
  */
144
131
  export interface CreateTrackedEventEmitterReturn<T> {
145
- /** Subscribe to an event with a callback, returns unsubscribe function */
146
132
  on: (event: string, callback: (data: T) => void) => () => void;
147
- /** Emit an event with data to all listeners */
148
133
  emit: (event: string, data: T) => void;
149
- /** Remove all listeners for a specific event or all events */
150
134
  removeAllListeners: (event?: string) => void;
151
- /** Subscription tracker for monitoring event activity */
152
135
  tracker: SubscriptionTracker<T>;
153
136
  }
154
137
  /**
@@ -175,17 +158,11 @@ export interface CreateTrackedEventEmitterReturn<T> {
175
158
  * ```
176
159
  */
177
160
  export interface DeferredPromise<T = void> {
178
- /** The promise that can be awaited */
179
161
  promise: Promise<T>;
180
- /** Function to resolve the promise with a value */
181
162
  resolve: (value: T) => void;
182
- /** Function to reject the promise with an error */
183
163
  reject: (error: unknown) => void;
184
- /** Whether the promise has been resolved */
185
164
  isResolved: boolean;
186
- /** Whether the promise has been rejected */
187
165
  isRejected: boolean;
188
- /** Whether the promise is still pending */
189
166
  isPending: boolean;
190
167
  }
191
168
  /**
@@ -203,11 +180,8 @@ export interface DeferredPromise<T = void> {
203
180
  * ```
204
181
  */
205
182
  export interface WaitOptions {
206
- /** Maximum time to wait in milliseconds (default: 5000) */
207
183
  timeout?: number;
208
- /** Polling interval in milliseconds (default: 50) */
209
184
  interval?: number;
210
- /** Custom error message if timeout is reached */
211
185
  message?: string;
212
186
  }
213
187
  /**
@@ -233,17 +207,11 @@ export interface WaitOptions {
233
207
  * ```
234
208
  */
235
209
  export interface RetryOptions {
236
- /** Maximum number of retry attempts (default: 3) */
237
210
  attempts?: number;
238
- /** Initial delay between retries in ms (default: 100) */
239
211
  delay?: number;
240
- /** Backoff multiplier for exponential delay (default: 2) */
241
212
  backoff?: number;
242
- /** Maximum delay between retries in ms (default: 10000) */
243
213
  maxDelay?: number;
244
- /** Function to determine if retry should occur based on error */
245
214
  shouldRetry?: (error: Error, attempt: number) => boolean;
246
- /** Callback invoked before each retry attempt */
247
215
  onRetry?: (error: Error, attempt: number) => void;
248
216
  }
249
217
  /**
@@ -270,15 +238,10 @@ export interface RetryOptions {
270
238
  * ```
271
239
  */
272
240
  export interface MockAsync<T = void> {
273
- /** The mock function that returns promises */
274
241
  mock: Vitest.Mock;
275
- /** Resolve the next pending promise with a value */
276
242
  resolve: (value: T) => void;
277
- /** Reject the next pending promise with an error */
278
243
  reject: (error: unknown) => void;
279
- /** Reset the mock and clear all pending promises */
280
244
  reset: () => void;
281
- /** Array of currently pending promises */
282
245
  pending: DeferredPromise<T>[];
283
246
  }
284
247
  /**
@@ -300,15 +263,10 @@ export interface MockAsync<T = void> {
300
263
  * ```
301
264
  */
302
265
  export interface ControllableTimer {
303
- /** Start the timer */
304
266
  start: () => void;
305
- /** Stop the timer */
306
267
  stop: () => void;
307
- /** Manually advance the timer by specified milliseconds */
308
268
  tick: (ms: number) => void;
309
- /** Reset the timer to zero */
310
269
  reset: () => void;
311
- /** Get elapsed time in milliseconds */
312
270
  elapsed: number;
313
271
  }
314
272
  /**
@@ -336,19 +294,12 @@ export interface ControllableTimer {
336
294
  * ```
337
295
  */
338
296
  export interface TestEventEmitter<T = unknown> {
339
- /** Add event listener, returns unsubscribe function */
340
297
  on: (handler: (data: T) => void) => () => void;
341
- /** Add one-time event listener, returns unsubscribe function */
342
298
  once: (handler: (data: T) => void) => () => void;
343
- /** Emit event synchronously to all listeners */
344
299
  emit: (data: T) => void;
345
- /** Emit event and wait for all async handlers to complete */
346
300
  emitAsync: (data: T) => Promise<void>;
347
- /** Remove all event listeners */
348
301
  removeAllListeners: () => void;
349
- /** Get current number of listeners */
350
302
  listenerCount: () => number;
351
- /** Wait for the next event with optional timeout */
352
303
  waitForEvent: (timeout?: number) => Promise<T>;
353
304
  }
354
305
  /**
@@ -378,15 +329,10 @@ export interface TestEventEmitter<T = unknown> {
378
329
  * ```
379
330
  */
380
331
  export interface AsyncTestStep<T = unknown> {
381
- /** Descriptive name for the step */
382
332
  name: string;
383
- /** Function to execute for this step */
384
333
  action: () => Promise<T> | T;
385
- /** Optional delay before executing this step (ms) */
386
334
  delay?: number;
387
- /** Optional assertion to run after step completes */
388
335
  assertion?: (result: T) => void | Promise<void>;
389
- /** Optional error handler for this step */
390
336
  onError?: (error: Error) => void;
391
337
  }
392
338
  /**
@@ -409,13 +355,9 @@ export interface AsyncTestStep<T = unknown> {
409
355
  * ```
410
356
  */
411
357
  export interface ConcurrentTestOptions {
412
- /** Array of async operations to execute */
413
358
  operations: Array<() => Promise<unknown>>;
414
- /** Maximum number of operations to run simultaneously */
415
359
  maxConcurrency?: number;
416
- /** Timeout for all operations in milliseconds */
417
360
  timeout?: number;
418
- /** Whether to expect some operations to fail */
419
361
  expectErrors?: boolean;
420
362
  }
421
363
  /**
@@ -435,13 +377,9 @@ export interface ConcurrentTestOptions {
435
377
  * ```
436
378
  */
437
379
  export interface RateLimitTestOptions {
438
- /** The operation to test for rate limiting */
439
380
  operation: () => Promise<unknown>;
440
- /** Target requests per second */
441
381
  requestsPerSecond: number;
442
- /** How long to run the test in milliseconds */
443
382
  duration: number;
444
- /** Whether to expect throttling to occur */
445
383
  expectThrottle?: boolean;
446
384
  }
447
385
  /**
@@ -467,13 +405,9 @@ export interface RateLimitTestOptions {
467
405
  * ```
468
406
  */
469
407
  export interface StateTransition<T> {
470
- /** Expected state before transition */
471
408
  from: T;
472
- /** Expected state after transition */
473
409
  to: T;
474
- /** Action that triggers the transition */
475
410
  action: () => Promise<void> | void;
476
- /** Optional delay after action before checking state */
477
411
  delay?: number;
478
412
  }
479
413
  /**
@@ -490,9 +424,7 @@ export interface StateTransition<T> {
490
424
  * ```
491
425
  */
492
426
  export interface EventSequence {
493
- /** Expected event names in order */
494
427
  events: string[];
495
- /** Whether events must occur in exact order (default: true) */
496
428
  strict?: boolean;
497
429
  }
498
430
  /**
@@ -518,11 +450,8 @@ export interface EventSequence {
518
450
  * ```
519
451
  */
520
452
  export interface AsyncCleanupItem {
521
- /** Descriptive name for the cleanup operation */
522
453
  name: string;
523
- /** Cleanup function to execute */
524
454
  cleanup: () => Promise<void> | void;
525
- /** Optional timeout for cleanup operation */
526
455
  timeout?: number;
527
456
  }
528
457
  /**
@@ -544,15 +473,10 @@ export interface AsyncCleanupItem {
544
473
  * ```
545
474
  */
546
475
  export interface PollingTestOptions {
547
- /** Function to call on each poll */
548
476
  pollFn: () => Promise<unknown> | unknown;
549
- /** Condition to check if polling should stop */
550
477
  condition: (result: unknown) => boolean;
551
- /** Maximum number of polling attempts */
552
478
  maxAttempts?: number;
553
- /** Interval between polls in milliseconds */
554
479
  interval?: number;
555
- /** Callback invoked after each poll */
556
480
  onPoll?: (attempt: number, result: unknown) => void;
557
481
  }
558
482
  /**
@@ -699,6 +623,24 @@ export interface TestBedConfig {
699
623
  imports?: unknown[];
700
624
  exports?: unknown[];
701
625
  }
626
+ /**
627
+ * Options for testing NestJS controllers.
628
+ * Configures controller dependencies and mocking.
629
+ *
630
+ * @template T - Type of controller being tested
631
+ *
632
+ * @example
633
+ * ```typescript
634
+ * const options: ControllerTestHarnessOptions<UserController> = {
635
+ * Controller: UserController,
636
+ * dependencies: [
637
+ * { token: UserService, value: mockUserService },
638
+ * { token: AuthGuard, value: mockAuthGuard }
639
+ * ],
640
+ * mockLogger: true
641
+ * };
642
+ * ```
643
+ */
702
644
  export interface ControllerTestHarnessOptions<T> {
703
645
  Controller: Type<T>;
704
646
  dependencies?: Array<{
@@ -707,6 +649,19 @@ export interface ControllerTestHarnessOptions<T> {
707
649
  }>;
708
650
  mockLogger?: boolean;
709
651
  }
652
+ /**
653
+ * Expected response from middleware validation.
654
+ * Used to assert middleware behavior in tests.
655
+ *
656
+ * @example
657
+ * ```typescript
658
+ * const expected: ValidateMiddlwareResponseExpected = {
659
+ * type: 'redirect',
660
+ * url: '/login',
661
+ * status: 302
662
+ * };
663
+ * ```
664
+ */
710
665
  export interface ValidateMiddlwareResponseExpected {
711
666
  type: 'next' | 'redirect' | 'rewrite' | 'response';
712
667
  url?: string;
@@ -739,6 +694,21 @@ export interface ServiceTestHarnessOptions<T> {
739
694
  mockLogger?: boolean;
740
695
  }
741
696
  export type NestModule = Type<unknown>;
697
+ /**
698
+ * Options for testing NestJS modules.
699
+ * Configures module dependencies and overrides.
700
+ *
701
+ * @example
702
+ * ```typescript
703
+ * const options: ModuleTestHarnessOptions = {
704
+ * Module: UserModule,
705
+ * overrideProviders: [
706
+ * { token: DatabaseService, useValue: mockDb },
707
+ * { token: CacheService, useFactory: () => mockCache }
708
+ * ]
709
+ * };
710
+ * ```
711
+ */
742
712
  export interface ModuleTestHarnessOptions {
743
713
  Module: NestModule;
744
714
  overrideProviders?: Array<{
@@ -747,6 +717,18 @@ export interface ModuleTestHarnessOptions {
747
717
  useFactory?: (...args: unknown[]) => unknown;
748
718
  }>;
749
719
  }
720
+ /**
721
+ * Options for testing Next.js pages.
722
+ * Extends React Testing Library render options with Next.js specific mocks.
723
+ *
724
+ * @example
725
+ * ```typescript
726
+ * const options: NextPageTestOptions = {
727
+ * router: { pathname: '/dashboard', query: { id: '123' } },
728
+ * mockModules: ['router', 'image']
729
+ * };
730
+ * ```
731
+ */
750
732
  export interface NextPageTestOptions extends RenderOptions {
751
733
  router?: Partial<MockNextRouter>;
752
734
  mockModules?: Array<'router' | 'image' | 'link' | 'head'>;
@@ -805,12 +787,43 @@ export interface MiddlewareTestContext {
805
787
  expectHeader: (name: string, value: string) => void;
806
788
  expectNext: () => void;
807
789
  }
790
+ /**
791
+ * Options for testing Next.js App Router hooks.
792
+ * Provides App Router specific context for hook testing.
793
+ *
794
+ * @template TProps - Type of hook props
795
+ *
796
+ * @example
797
+ * ```typescript
798
+ * const options: AppRouterHookTestOptions<UseUserProps> = {
799
+ * pathname: '/user/profile',
800
+ * searchParams: { tab: 'settings' },
801
+ * params: { userId: '123' }
802
+ * };
803
+ * ```
804
+ */
808
805
  export interface AppRouterHookTestOptions<TProps> extends RenderHookOptions<TProps> {
809
806
  pathname?: string;
810
807
  searchParams?: Record<string, string | string[]>;
811
808
  params?: Record<string, string | string[]>;
812
809
  }
813
810
  export type UserEvent = UserEventLib;
811
+ /**
812
+ * Configuration for user event simulation.
813
+ * Controls timing and behavior of simulated user interactions.
814
+ *
815
+ * @example
816
+ * ```typescript
817
+ * const config: UserEventConfig = {
818
+ * delay: 10, // 10ms between keystrokes
819
+ * advanceTimers: vi.advanceTimersByTime,
820
+ * applyAccept: true,
821
+ * autoModify: true,
822
+ * skipAutoClose: false,
823
+ * writeToClipboard: true
824
+ * };
825
+ * ```
826
+ */
814
827
  export interface UserEventConfig {
815
828
  delay?: number;
816
829
  advanceTimers?: (ms: number) => void | Promise<void>;
@@ -859,6 +872,19 @@ export interface InteractionSequence {
859
872
  distance?: number;
860
873
  };
861
874
  }
875
+ /**
876
+ * Mock child process instance for testing.
877
+ * Simulates Node.js child process behavior.
878
+ *
879
+ * @example
880
+ * ```typescript
881
+ * const mockProcess: MockChildProcessInstance = {
882
+ * stdout: { on: { mock: { calls: [] } } },
883
+ * stderr: { on: { mock: { calls: [] } } },
884
+ * on: { mock: { calls: [] } }
885
+ * };
886
+ * ```
887
+ */
862
888
  export interface MockChildProcessInstance {
863
889
  stdout: {
864
890
  on: {
@@ -881,6 +907,21 @@ export interface MockChildProcessInstance {
881
907
  };
882
908
  [key: string]: unknown;
883
909
  }
910
+ /**
911
+ * Utilities for testing process-level operations.
912
+ * Provides helpers for simulating process events and signals.
913
+ *
914
+ * @example
915
+ * ```typescript
916
+ * const utils: ProcessTestUtils = {
917
+ * simulateSignal: (signal) => process.emit(signal),
918
+ * expectExit: (code) => expect(process.exit).toHaveBeenCalledWith(code),
919
+ * captureOutput: () => ({ stdout: [], stderr: [] }),
920
+ * simulateUncaughtException: (error) => process.emit('uncaughtException', error),
921
+ * simulateUnhandledRejection: (reason) => process.emit('unhandledRejection', reason)
922
+ * };
923
+ * ```
924
+ */
884
925
  export interface ProcessTestUtils {
885
926
  simulateSignal: (signal: string) => void;
886
927
  expectExit: (code?: number) => void;
@@ -891,6 +932,21 @@ export interface ProcessTestUtils {
891
932
  simulateUncaughtException: (error: Error) => void;
892
933
  simulateUnhandledRejection: (reason: unknown) => void;
893
934
  }
935
+ /**
936
+ * Utilities for testing child process operations.
937
+ * Provides helpers for asserting and simulating child process behavior.
938
+ *
939
+ * @example
940
+ * ```typescript
941
+ * const utils: ChildProcessTestUtils = {
942
+ * expectCommand: (cmd, args) => expect(spawn).toHaveBeenCalledWith(cmd, args),
943
+ * simulateOutput: (stdout, stderr) => mockProcess.stdout.emit('data', stdout),
944
+ * simulateError: (error) => mockProcess.emit('error', error),
945
+ * simulateExit: (code) => mockProcess.emit('exit', code),
946
+ * getLastProcess: () => mockProcesses[mockProcesses.length - 1]
947
+ * };
948
+ * ```
949
+ */
894
950
  export interface ChildProcessTestUtils {
895
951
  expectCommand: (command: string, args?: string[]) => void;
896
952
  simulateOutput: (stdout: string, stderr?: string) => void;
@@ -898,12 +954,41 @@ export interface ChildProcessTestUtils {
898
954
  simulateExit: (code: number) => void;
899
955
  getLastProcess: () => unknown;
900
956
  }
957
+ /**
958
+ * Utilities for testing stream operations.
959
+ * Provides helpers for simulating stream behavior.
960
+ *
961
+ * @example
962
+ * ```typescript
963
+ * const utils: StreamTestUtils = {
964
+ * pipeData: (data) => stream.write(data),
965
+ * endStream: () => stream.end(),
966
+ * expectPipedTo: (dest) => expect(stream.pipe).toHaveBeenCalledWith(dest),
967
+ * getWrittenData: () => writtenChunks
968
+ * };
969
+ * ```
970
+ */
901
971
  export interface StreamTestUtils {
902
972
  pipeData: (data: string | globalThis.Buffer) => void;
903
973
  endStream: () => void;
904
974
  expectPipedTo: (destination: unknown) => void;
905
975
  getWrittenData: () => Array<string | globalThis.Buffer>;
906
976
  }
977
+ /**
978
+ * Utilities for testing event-driven systems.
979
+ * Provides helpers for event simulation and assertion.
980
+ *
981
+ * @example
982
+ * ```typescript
983
+ * const utils: EventDrivenTestUtils = {
984
+ * emitter: createMockEventEmitter(),
985
+ * expectEvent: (event, payload) => expect(emitter.emit).toHaveBeenCalledWith(event, payload),
986
+ * expectNoEvent: (event) => expect(emitter.emit).not.toHaveBeenCalledWith(event),
987
+ * simulateEvents: async (events) => { // simulate },
988
+ * getEventHistory: () => eventHistory
989
+ * };
990
+ * ```
991
+ */
907
992
  export interface EventDrivenTestUtils {
908
993
  emitter: MockEventEmitter;
909
994
  expectEvent: (event: string, payload?: unknown) => void;
@@ -911,18 +996,60 @@ export interface EventDrivenTestUtils {
911
996
  simulateEvents: (events: Array<SimulatedEvent>) => Promise<void>;
912
997
  getEventHistory: () => Array<EventHistoryEntry>;
913
998
  }
999
+ /**
1000
+ * Test server instance for integration testing.
1001
+ * Provides methods to manage a test server lifecycle.
1002
+ *
1003
+ * @example
1004
+ * ```typescript
1005
+ * const server: TestServer = {
1006
+ * url: 'http://localhost:3000',
1007
+ * port: 3000,
1008
+ * close: async () => await serverInstance.close(),
1009
+ * on: (event, handler) => serverInstance.on(event, handler)
1010
+ * };
1011
+ * ```
1012
+ */
914
1013
  export interface TestServer {
915
1014
  url: string;
916
1015
  port: number;
917
1016
  close: () => Promise<void>;
918
1017
  on: (event: string, handler: Function) => void;
919
1018
  }
1019
+ /**
1020
+ * Result from a single concurrent operation.
1021
+ * Contains success status and timing information.
1022
+ *
1023
+ * @example
1024
+ * ```typescript
1025
+ * const result: ConcurrentOperationResult = {
1026
+ * success: true,
1027
+ * result: { id: 1, status: 'uploaded' },
1028
+ * duration: 250
1029
+ * };
1030
+ * ```
1031
+ */
920
1032
  export interface ConcurrentOperationResult {
921
1033
  success: boolean;
922
1034
  result?: unknown;
923
1035
  error?: Error;
924
1036
  duration: number;
925
1037
  }
1038
+ /**
1039
+ * Aggregated results from concurrent operations testing.
1040
+ * Contains statistics across all concurrent operations.
1041
+ *
1042
+ * @example
1043
+ * ```typescript
1044
+ * const result: ConcurrentTestResult = {
1045
+ * results: [ ...operation results ],
1046
+ * totalDuration: 5000,
1047
+ * successCount: 95,
1048
+ * errorCount: 5,
1049
+ * averageDuration: 250
1050
+ * };
1051
+ * ```
1052
+ */
926
1053
  export interface ConcurrentTestResult {
927
1054
  results: ConcurrentOperationResult[];
928
1055
  totalDuration: number;
@@ -930,48 +1057,168 @@ export interface ConcurrentTestResult {
930
1057
  errorCount: number;
931
1058
  averageDuration: number;
932
1059
  }
1060
+ /**
1061
+ * Result from a single rate-limited request.
1062
+ * Contains timing and success information.
1063
+ *
1064
+ * @example
1065
+ * ```typescript
1066
+ * const result: RateLimitResult = {
1067
+ * timestamp: Date.now(),
1068
+ * success: true
1069
+ * };
1070
+ * ```
1071
+ */
933
1072
  export interface RateLimitResult {
934
1073
  timestamp: number;
935
1074
  success: boolean;
936
1075
  error?: Error;
937
1076
  }
1077
+ /**
1078
+ * Aggregated results from rate limit testing.
1079
+ * Contains actual rate and throttling information.
1080
+ *
1081
+ * @example
1082
+ * ```typescript
1083
+ * const result: RateLimitTestResult = {
1084
+ * results: [ ...individual results ],
1085
+ * actualRate: 9.5, // requests per second
1086
+ * wasThrottled: true
1087
+ * };
1088
+ * ```
1089
+ */
938
1090
  export interface RateLimitTestResult {
939
1091
  results: RateLimitResult[];
940
1092
  actualRate: number;
941
1093
  wasThrottled: boolean;
942
1094
  }
1095
+ /**
1096
+ * Single polling attempt record.
1097
+ * Contains attempt number and result data.
1098
+ *
1099
+ * @example
1100
+ * ```typescript
1101
+ * const attempt: PollingAttempt = {
1102
+ * attempt: 3,
1103
+ * result: { status: 'processing' },
1104
+ * timestamp: Date.now()
1105
+ * };
1106
+ * ```
1107
+ */
943
1108
  export interface PollingAttempt {
944
1109
  attempt: number;
945
1110
  result: unknown;
946
1111
  timestamp: number;
947
1112
  }
1113
+ /**
1114
+ * Results from polling operation testing.
1115
+ * Contains attempt history and success status.
1116
+ *
1117
+ * @example
1118
+ * ```typescript
1119
+ * const result: PollingTestResult = {
1120
+ * attempts: [ ..polling attempts ],
1121
+ * conditionMet: true,
1122
+ * totalAttempts: 5,
1123
+ * totalDuration: 4500
1124
+ * };
1125
+ * ```
1126
+ */
948
1127
  export interface PollingTestResult {
949
1128
  attempts: PollingAttempt[];
950
1129
  conditionMet: boolean;
951
1130
  totalAttempts: number;
952
1131
  totalDuration: number;
953
1132
  }
1133
+ /**
1134
+ * Results from debounce testing.
1135
+ * Tracks call count and timing.
1136
+ *
1137
+ * @example
1138
+ * ```typescript
1139
+ * const result: DebounceTestResult = {
1140
+ * callCount: 1,
1141
+ * lastCallTime: Date.now()
1142
+ * };
1143
+ * ```
1144
+ */
954
1145
  export interface DebounceTestResult {
955
1146
  callCount: number;
956
1147
  lastCallTime: number;
957
1148
  }
1149
+ /**
1150
+ * Single throttled call record.
1151
+ * Contains arguments and delay information.
1152
+ *
1153
+ * @example
1154
+ * ```typescript
1155
+ * const call: ThrottleCall = {
1156
+ * args: ['data', { id: 1 }],
1157
+ * delay: 100
1158
+ * };
1159
+ * ```
1160
+ */
958
1161
  export interface ThrottleCall {
959
1162
  args: unknown[];
960
1163
  delay: number;
961
1164
  }
1165
+ /**
1166
+ * Result from throttle testing.
1167
+ * Indicates whether call was executed.
1168
+ *
1169
+ * @example
1170
+ * ```typescript
1171
+ * const result: ThrottleResult = {
1172
+ * called: true,
1173
+ * args: ['test', 123]
1174
+ * };
1175
+ * ```
1176
+ */
962
1177
  export interface ThrottleResult {
963
1178
  called: boolean;
964
1179
  args?: unknown[];
965
1180
  }
1181
+ /**
1182
+ * Async testing scenario definition.
1183
+ * Defines setup, action, and verification steps.
1184
+ *
1185
+ * @template T - Type of value returned by action
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * const scenario: AsyncScenario<User> = {
1190
+ * name: 'Create user flow',
1191
+ * setup: async () => await db.connect(),
1192
+ * action: async () => await createUser({ name: 'Test' }),
1193
+ * verify: (user) => expect(user.id).toBeDefined(),
1194
+ * cleanup: async () => await db.disconnect(),
1195
+ * expectedHooks: ['beforeCreate', 'afterCreate']
1196
+ * };
1197
+ * ```
1198
+ */
966
1199
  export interface AsyncScenario<T = void> {
967
1200
  name: string;
968
1201
  setup: () => Promise<void>;
969
1202
  action: () => Promise<T>;
970
1203
  verify: (result: T) => void | Promise<void>;
971
1204
  cleanup?: () => Promise<void>;
972
- /** Expected hooks */
973
1205
  expectedHooks: string[];
974
1206
  }
1207
+ /**
1208
+ * Options for waiting for value changes.
1209
+ * Configures polling and comparison behavior.
1210
+ *
1211
+ * @template T - Type of value being watched
1212
+ *
1213
+ * @example
1214
+ * ```typescript
1215
+ * const options: WaitForChangeOptions<number> = {
1216
+ * timeout: 5000,
1217
+ * interval: 100,
1218
+ * compareFn: (a, b) => Math.abs(a - b) > 0.01
1219
+ * };
1220
+ * ```
1221
+ */
975
1222
  export interface WaitForChangeOptions<T> {
976
1223
  timeout?: number;
977
1224
  interval?: number;
@@ -1004,24 +1251,92 @@ export interface PerformanceMetrics {
1004
1251
  p99: number;
1005
1252
  runs: number[];
1006
1253
  }
1254
+ /**
1255
+ * Options for timing measurements.
1256
+ * Configures warmup and run counts.
1257
+ *
1258
+ * @example
1259
+ * ```typescript
1260
+ * const options: MeasureTimeOptions = {
1261
+ * warmup: 10,
1262
+ * runs: 100
1263
+ * };
1264
+ * ```
1265
+ */
1007
1266
  export interface MeasureTimeOptions {
1008
1267
  warmup?: number;
1009
1268
  runs?: number;
1010
1269
  }
1270
+ /**
1271
+ * Result from timing measurement.
1272
+ * Contains result value and performance metrics.
1273
+ *
1274
+ * @template T - Type of value returned by measured function
1275
+ *
1276
+ * @example
1277
+ * ```typescript
1278
+ * const result: MeasureTimeResult<string> = {
1279
+ * result: 'processed',
1280
+ * duration: 125,
1281
+ * metrics: { ...performance metrics }
1282
+ * };
1283
+ * ```
1284
+ */
1011
1285
  export interface MeasureTimeResult<T> {
1012
1286
  result: T;
1013
1287
  duration: number;
1014
1288
  metrics?: PerformanceMetrics;
1015
1289
  }
1290
+ /**
1291
+ * Benchmark results by function name.
1292
+ * Maps function names to their performance metrics.
1293
+ *
1294
+ * @example
1295
+ * ```typescript
1296
+ * const result: BenchmarkResult = {
1297
+ * 'sort': { mean: 25, median: 24, ... },
1298
+ * 'filter': { mean: 15, median: 14, ... }
1299
+ * };
1300
+ * ```
1301
+ */
1016
1302
  export interface BenchmarkResult {
1017
1303
  [functionName: string]: PerformanceMetrics;
1018
1304
  }
1305
+ /**
1306
+ * Options for load testing.
1307
+ * Configures duration, concurrency, and ramp-up.
1308
+ *
1309
+ * @example
1310
+ * ```typescript
1311
+ * const options: LoadTestOptions = {
1312
+ * duration: 60000, // 1 minute
1313
+ * concurrency: 50,
1314
+ * rampUp: 5000, // 5 seconds
1315
+ * onProgress: (stats) => console.log('Progress:', stats)
1316
+ * };
1317
+ * ```
1318
+ */
1019
1319
  export interface LoadTestOptions {
1020
1320
  duration?: number;
1021
1321
  concurrency?: number;
1022
1322
  rampUp?: number;
1023
1323
  onProgress?: (stats: LoadTestStats) => void;
1024
1324
  }
1325
+ /**
1326
+ * Statistics collected during load testing.
1327
+ * Contains request counts and latency data.
1328
+ *
1329
+ * @example
1330
+ * ```typescript
1331
+ * const stats: LoadTestStats = {
1332
+ * totalRequests: 5000,
1333
+ * successfulRequests: 4950,
1334
+ * failedRequests: 50,
1335
+ * latencies: [120, 125, 130, ...],
1336
+ * errors: [ ..rror objects ]
1337
+ * };
1338
+ * ```
1339
+ */
1025
1340
  export interface LoadTestStats {
1026
1341
  totalRequests: number;
1027
1342
  successfulRequests: number;
@@ -1054,35 +1369,146 @@ export interface LoadTestResult {
1054
1369
  throughput: number;
1055
1370
  errors: Error[];
1056
1371
  }
1372
+ /**
1373
+ * Options for CPU profiling.
1374
+ * Configures sampling interval.
1375
+ *
1376
+ * @example
1377
+ * ```typescript
1378
+ * const options: ProfileCPUOptions = {
1379
+ * sampleInterval: 10 // sample every 10ms
1380
+ * };
1381
+ * ```
1382
+ */
1057
1383
  export interface ProfileCPUOptions {
1058
1384
  sampleInterval?: number;
1059
1385
  }
1386
+ /**
1387
+ * CPU profile data.
1388
+ * Contains samples and timing information.
1389
+ *
1390
+ * @example
1391
+ * ```typescript
1392
+ * const profile: CPUProfile = {
1393
+ * samples: [15, 20, 18, 22, 25],
1394
+ * duration: 1000
1395
+ * };
1396
+ * ```
1397
+ */
1060
1398
  export interface CPUProfile {
1061
1399
  samples: number[];
1062
1400
  duration: number;
1063
1401
  }
1402
+ /**
1403
+ * Result from CPU profiling.
1404
+ * Contains function result and CPU profile.
1405
+ *
1406
+ * @template T - Type of value returned by profiled function
1407
+ *
1408
+ * @example
1409
+ * ```typescript
1410
+ * const result: ProfileCPUResult<number> = {
1411
+ * result: 42,
1412
+ * profile: { samples: [...CPU samples ], duration: 1000 }
1413
+ * };
1414
+ * ```
1415
+ */
1064
1416
  export interface ProfileCPUResult<T> {
1065
1417
  result: T;
1066
1418
  profile: CPUProfile;
1067
1419
  }
1420
+ /**
1421
+ * Options for scalability testing.
1422
+ * Configures expected complexity and tolerance.
1423
+ *
1424
+ * @example
1425
+ * ```typescript
1426
+ * const options: ScalabilityTestOptions = {
1427
+ * expectedComplexity: 'linear',
1428
+ * tolerance: 0.1 // 10% tolerance
1429
+ * };
1430
+ * ```
1431
+ */
1068
1432
  export interface ScalabilityTestOptions {
1069
1433
  expectedComplexity?: 'constant' | 'logarithmic' | 'linear' | 'quadratic';
1070
1434
  tolerance?: number;
1071
1435
  }
1436
+ /**
1437
+ * Single scalability measurement point.
1438
+ * Contains input size and execution time.
1439
+ *
1440
+ * @example
1441
+ * ```typescript
1442
+ * const measurement: ScalabilityMeasurement = {
1443
+ * size: 1000,
1444
+ * time: 250 // milliseconds
1445
+ * };
1446
+ * ```
1447
+ */
1072
1448
  export interface ScalabilityMeasurement {
1073
1449
  size: number;
1074
1450
  time: number;
1075
1451
  }
1452
+ /**
1453
+ * Results from scalability testing.
1454
+ * Contains complexity analysis and measurements.
1455
+ *
1456
+ * @example
1457
+ * ```typescript
1458
+ * const result: ScalabilityTestResult = {
1459
+ * measurements: [ ...measurement points ],
1460
+ * complexity: 'O(n)',
1461
+ * isWithinExpected: true
1462
+ * };
1463
+ * ```
1464
+ */
1076
1465
  export interface ScalabilityTestResult {
1077
1466
  measurements: ScalabilityMeasurement[];
1078
1467
  complexity: string;
1079
1468
  isWithinExpected: boolean;
1080
1469
  }
1081
- export interface PerformanceComparisonOptions {
1082
- runs?: number;
1083
- chart?: boolean;
1084
- }
1085
- export interface PerformanceComparisonInput<T> {
1470
+ /**
1471
+ * Options for performance comparison testing.
1472
+ * Configures comparison runs and visualization preferences.
1473
+ *
1474
+ * @example
1475
+ * ```typescript
1476
+ * const options: PerformanceComparisonOptions = {
1477
+ * runs: 100,
1478
+ * chart: true
1479
+ * };
1480
+ *
1481
+ * const result = await comparePerformance([
1482
+ * { name: 'quickSort', fn: () => quickSort(data) },
1483
+ * { name: 'mergeSort', fn: () => mergeSort(data) }
1484
+ * ], options);
1485
+ * ```
1486
+ */
1487
+ export interface PerformanceComparisonOptions {
1488
+ runs?: number;
1489
+ chart?: boolean;
1490
+ }
1491
+ /**
1492
+ * Input data for performance comparison testing.
1493
+ * Represents a named test case with associated value or function.
1494
+ *
1495
+ * @template T - Type of the comparison input value
1496
+ *
1497
+ * @example
1498
+ * ```typescript
1499
+ * const inputs: PerformanceComparisonInput<() => number[]>[] = [
1500
+ * {
1501
+ * name: 'Bubble Sort',
1502
+ * value: () => bubbleSort([...testData])
1503
+ * },
1504
+ * {
1505
+ * name: 'Quick Sort',
1506
+ * value: () => quickSort([...testData])
1507
+ * }
1508
+ * ];
1509
+ * ```
1510
+ */
1511
+ export interface PerformanceComparisonInput<T> {
1086
1512
  name: string;
1087
1513
  value: T;
1088
1514
  }
@@ -1106,33 +1532,152 @@ export interface MemoryMeasurement {
1106
1532
  delta: number;
1107
1533
  peak: number;
1108
1534
  }
1535
+ /**
1536
+ * Options for memory measurement during testing.
1537
+ * Configures garbage collection and test run parameters.
1538
+ *
1539
+ * @example
1540
+ * ```typescript
1541
+ * const options: MeasureMemoryOptions = {
1542
+ * forceGC: true,
1543
+ * runs: 5
1544
+ * };
1545
+ *
1546
+ * const result = await measureMemory(() => {
1547
+ * return processLargeDataset(data);
1548
+ * }, options);
1549
+ * ```
1550
+ */
1109
1551
  export interface MeasureMemoryOptions {
1110
1552
  forceGC?: boolean;
1111
1553
  runs?: number;
1112
1554
  }
1555
+ /**
1556
+ * Result from memory measurement testing.
1557
+ * Contains the function result and memory usage statistics.
1558
+ *
1559
+ * @template T - Type of the measured function's return value
1560
+ *
1561
+ * @example
1562
+ * ```typescript
1563
+ * const result: MeasureMemoryResult<ProcessedData> = {
1564
+ * result: processedData,
1565
+ * memory: {
1566
+ * before: 50 * 1024 * 1024,
1567
+ * after: 75 * 1024 * 1024,
1568
+ * delta: 25 * 1024 * 1024,
1569
+ * peak: 80 * 1024 * 1024
1570
+ * }
1571
+ * };
1572
+ * ```
1573
+ */
1113
1574
  export interface MeasureMemoryResult<T> {
1114
1575
  result: T;
1115
1576
  memory: MemoryMeasurement;
1116
1577
  }
1578
+ /**
1579
+ * Performance constraints for testing operations.
1580
+ * Defines maximum acceptable limits for time, memory, and throughput.
1581
+ *
1582
+ * @example
1583
+ * ```typescript
1584
+ * const constraints: PerformanceConstraints = {
1585
+ * maxTime: 1000, // 1 second
1586
+ * maxMemory: 100 * 1024 * 1024, // 100MB
1587
+ * minThroughput: 1000 // 1000 operations per second
1588
+ * };
1589
+ *
1590
+ * await assertPerformance(() => processData(), constraints);
1591
+ * ```
1592
+ */
1117
1593
  export interface PerformanceConstraints {
1118
1594
  maxTime?: number;
1119
1595
  maxMemory?: number;
1120
1596
  minThroughput?: number;
1121
1597
  }
1598
+ /**
1599
+ * Options for performance assertion testing.
1600
+ * Configures test runs and duration for performance validation.
1601
+ *
1602
+ * @example
1603
+ * ```typescript
1604
+ * const options: AssertPerformanceOptions = {
1605
+ * runs: 10,
1606
+ * duration: 5000 // 5 seconds total test duration
1607
+ * };
1608
+ *
1609
+ * await assertPerformance(() => {
1610
+ * return expensiveOperation();
1611
+ * }, constraints, options);
1612
+ * ```
1613
+ */
1122
1614
  export interface AssertPerformanceOptions {
1123
1615
  runs?: number;
1124
1616
  duration?: number;
1125
1617
  }
1618
+ /**
1619
+ * Entry in event history tracking.
1620
+ * Records event name, payload, and timestamp for testing event sequences.
1621
+ *
1622
+ * @example
1623
+ * ```typescript
1624
+ * const entry: EventHistoryEntry = {
1625
+ * event: 'user:login',
1626
+ * payload: { userId: '123', timestamp: Date.now() },
1627
+ * timestamp: 1640995200000
1628
+ * };
1629
+ * ```
1630
+ */
1126
1631
  export interface EventHistoryEntry {
1127
1632
  event: string;
1128
1633
  payload: unknown;
1129
1634
  timestamp: number;
1130
1635
  }
1636
+ /**
1637
+ * Configuration for simulating events in tests.
1638
+ * Defines event name, payload, and optional delay for event simulation.
1639
+ *
1640
+ * @example
1641
+ * ```typescript
1642
+ * const simulatedEvents: SimulatedEvent[] = [
1643
+ * {
1644
+ * event: 'connect',
1645
+ * payload: { connectionId: 'conn-123' }
1646
+ * },
1647
+ * {
1648
+ * event: 'message',
1649
+ * payload: { text: 'Hello World' },
1650
+ * delay: 100
1651
+ * },
1652
+ * {
1653
+ * event: 'disconnect',
1654
+ * delay: 5000
1655
+ * }
1656
+ * ];
1657
+ * ```
1658
+ */
1131
1659
  export interface SimulatedEvent {
1132
1660
  event: string;
1133
1661
  payload?: unknown;
1134
1662
  delay?: number;
1135
1663
  }
1664
+ /**
1665
+ * Configuration options for mocking WebSocket connections.
1666
+ * Defines WebSocket properties and state for testing.
1667
+ *
1668
+ * @example
1669
+ * ```typescript
1670
+ * const options: WebSocketMockOptions = {
1671
+ * url: 'ws://localhost:8080',
1672
+ * protocol: 'chat',
1673
+ * extensions: 'permessage-deflate',
1674
+ * readyState: WebSocket.OPEN,
1675
+ * bufferedAmount: 0
1676
+ * };
1677
+ *
1678
+ * const mockWS = createMockWebSocket(options);
1679
+ * ```
1680
+ */
1136
1681
  export interface WebSocketMockOptions {
1137
1682
  url?: string;
1138
1683
  protocol?: string;
@@ -1140,6 +1685,21 @@ export interface WebSocketMockOptions {
1140
1685
  readyState?: number;
1141
1686
  bufferedAmount?: number;
1142
1687
  }
1688
+ /**
1689
+ * Configuration options for mocking WebSocket servers.
1690
+ * Defines server properties and connection limits for testing.
1691
+ *
1692
+ * @example
1693
+ * ```typescript
1694
+ * const serverOptions: WebSocketServerMockOptions = {
1695
+ * port: 8080,
1696
+ * host: 'localhost',
1697
+ * maxClients: 100
1698
+ * };
1699
+ *
1700
+ * const mockServer = createMockWebSocketServer(serverOptions);
1701
+ * ```
1702
+ */
1143
1703
  export interface WebSocketServerMockOptions {
1144
1704
  port?: number;
1145
1705
  host?: string;
@@ -1169,6 +1729,24 @@ export interface WebSocketTestScenario {
1169
1729
  shouldError?: boolean;
1170
1730
  errorMessage?: string;
1171
1731
  }
1732
+ /**
1733
+ * Configuration options for WebSocket connections in tests.
1734
+ * Defines connection parameters and behavior settings.
1735
+ *
1736
+ * @example
1737
+ * ```typescript
1738
+ * const connectionOptions: WebSocketConnectionOptions = {
1739
+ * url: 'wss://api.example.com/ws',
1740
+ * protocols: ['chat', 'notifications'],
1741
+ * headers: {
1742
+ * 'Authorization': 'Bearer token123'
1743
+ * },
1744
+ * timeout: 10000
1745
+ * };
1746
+ *
1747
+ * const ws = await connectWebSocket(connectionOptions);
1748
+ * ```
1749
+ */
1172
1750
  export interface WebSocketConnectionOptions {
1173
1751
  url: string;
1174
1752
  protocols?: string | string[];
@@ -1200,6 +1778,28 @@ export interface FileOperationTest {
1200
1778
  expectedFiles?: Map<string, string | globalThis.Buffer>;
1201
1779
  expectedError?: string | RegExp;
1202
1780
  }
1781
+ /**
1782
+ * Test configuration for process signals.
1783
+ * Defines signal name and expected behavior for testing signal handling.
1784
+ *
1785
+ * @example
1786
+ * ```typescript
1787
+ * const signalTests: SignalTest[] = [
1788
+ * {
1789
+ * signal: 'SIGTERM',
1790
+ * expectedBehavior: () => {
1791
+ * expect(gracefulShutdown).toHaveBeenCalled();
1792
+ * }
1793
+ * },
1794
+ * {
1795
+ * signal: 'SIGINT',
1796
+ * expectedBehavior: () => {
1797
+ * expect(process.exit).toHaveBeenCalledWith(0);
1798
+ * }
1799
+ * }
1800
+ * ];
1801
+ * ```
1802
+ */
1203
1803
  export interface SignalTest {
1204
1804
  signal: string;
1205
1805
  expectedBehavior: () => void;
@@ -1241,17 +1841,82 @@ export interface AriaAttributes {
1241
1841
  role?: string;
1242
1842
  tabIndex?: number;
1243
1843
  }
1844
+ /**
1845
+ * Test configuration for keyboard navigation behavior.
1846
+ * Defines element, key press, and expected navigation outcome.
1847
+ *
1848
+ * @example
1849
+ * ```typescript
1850
+ * const navTests: KeyboardNavigationTest[] = [
1851
+ * {
1852
+ * element: submitButton,
1853
+ * key: 'Enter',
1854
+ * expectedBehavior: 'activate'
1855
+ * },
1856
+ * {
1857
+ * element: inputField,
1858
+ * key: 'Tab',
1859
+ * expectedBehavior: 'navigate',
1860
+ * expectedTarget: nextButton
1861
+ * }
1862
+ * ];
1863
+ * ```
1864
+ */
1244
1865
  export interface KeyboardNavigationTest {
1245
1866
  element: HTMLElement;
1246
1867
  key: string;
1247
1868
  expectedBehavior: 'focus' | 'activate' | 'navigate' | 'ignore';
1248
1869
  expectedTarget?: HTMLElement;
1249
1870
  }
1871
+ /**
1872
+ * Test configuration for screen reader accessibility.
1873
+ * Defines element and expected screen reader text output.
1874
+ *
1875
+ * @example
1876
+ * ```typescript
1877
+ * const screenReaderTests: ScreenReaderTest[] = [
1878
+ * {
1879
+ * element: submitButton,
1880
+ * expectedText: 'Submit form button',
1881
+ * includeHidden: false
1882
+ * },
1883
+ * {
1884
+ * element: errorMessage,
1885
+ * expectedText: /error|invalid|required/i,
1886
+ * includeHidden: true
1887
+ * }
1888
+ * ];
1889
+ * ```
1890
+ */
1250
1891
  export interface ScreenReaderTest {
1251
1892
  element: HTMLElement;
1252
1893
  expectedText: string | RegExp;
1253
1894
  includeHidden?: boolean;
1254
1895
  }
1896
+ /**
1897
+ * Configuration for lifecycle hook testing.
1898
+ * Defines hook properties and execution characteristics.
1899
+ *
1900
+ * @example
1901
+ * ```typescript
1902
+ * const hooks: LifecycleHook[] = [
1903
+ * {
1904
+ * name: 'componentDidMount',
1905
+ * method: 'componentDidMount',
1906
+ * phase: 'mount',
1907
+ * required: true,
1908
+ * async: false
1909
+ * },
1910
+ * {
1911
+ * name: 'onModuleInit',
1912
+ * method: 'onModuleInit',
1913
+ * phase: 'init',
1914
+ * required: false,
1915
+ * async: true
1916
+ * }
1917
+ * ];
1918
+ * ```
1919
+ */
1255
1920
  export interface LifecycleHook {
1256
1921
  name: string;
1257
1922
  method: string;
@@ -1289,6 +1954,31 @@ export interface ComponentLifecycleTest {
1289
1954
  expectedHooksAfter: string[];
1290
1955
  }>;
1291
1956
  }
1957
+ /**
1958
+ * Interface for services that support NestJS lifecycle hooks.
1959
+ * Defines optional lifecycle methods for service initialization and cleanup.
1960
+ *
1961
+ * @example
1962
+ * ```typescript
1963
+ * class DatabaseService implements ServiceWithLifecycle {
1964
+ * async onModuleInit() {
1965
+ * await this.connect();
1966
+ * }
1967
+ *
1968
+ * async onModuleDestroy() {
1969
+ * await this.disconnect();
1970
+ * }
1971
+ *
1972
+ * async onApplicationBootstrap() {
1973
+ * await this.runMigrations();
1974
+ * }
1975
+ *
1976
+ * async onApplicationShutdown() {
1977
+ * await this.gracefulShutdown();
1978
+ * }
1979
+ * }
1980
+ * ```
1981
+ */
1292
1982
  export interface ServiceWithLifecycle {
1293
1983
  onModuleInit?: () => Promise<void>;
1294
1984
  onModuleDestroy?: () => Promise<void>;
@@ -1296,6 +1986,24 @@ export interface ServiceWithLifecycle {
1296
1986
  onApplicationShutdown?: () => Promise<void>;
1297
1987
  [key: string]: unknown;
1298
1988
  }
1989
+ /**
1990
+ * Test configuration for service lifecycle hooks.
1991
+ * Defines service class and expected lifecycle behavior for testing.
1992
+ *
1993
+ * @example
1994
+ * ```typescript
1995
+ * const serviceTest: ServiceLifecycleTest = {
1996
+ * name: 'DatabaseService lifecycle',
1997
+ * Service: DatabaseService,
1998
+ * dependencies: [mockConfig, mockLogger],
1999
+ * expectedHooks: [
2000
+ * { name: 'onModuleInit', method: 'onModuleInit', phase: 'init', async: true },
2001
+ * { name: 'onModuleDestroy', method: 'onModuleDestroy', phase: 'destroy', async: true }
2002
+ * ],
2003
+ * cleanupExpected: true
2004
+ * };
2005
+ * ```
2006
+ */
1299
2007
  export interface ServiceLifecycleTest {
1300
2008
  name: string;
1301
2009
  Service: new (...args: unknown[]) => ServiceWithLifecycle;
@@ -1303,6 +2011,19 @@ export interface ServiceLifecycleTest {
1303
2011
  expectedHooks: LifecycleHook[];
1304
2012
  cleanupExpected?: boolean;
1305
2013
  }
2014
+ /**
2015
+ * Provider with lifecycle hooks.
2016
+ * Contains constructor name and lifecycle methods.
2017
+ *
2018
+ * @example
2019
+ * ```typescript
2020
+ * const provider: ProviderWithLifecycle = {
2021
+ * constructor: { name: 'CacheProvider' },
2022
+ * onModuleInit: async () => { await cache.warm(); },
2023
+ * onModuleDestroy: async () => { await cache.clear(); }
2024
+ * };
2025
+ * ```
2026
+ */
1306
2027
  export interface ProviderWithLifecycle {
1307
2028
  constructor: {
1308
2029
  name: string;
@@ -1311,6 +2032,21 @@ export interface ProviderWithLifecycle {
1311
2032
  onModuleDestroy?: () => Promise<void>;
1312
2033
  [key: string]: unknown;
1313
2034
  }
2035
+ /**
2036
+ * Test configuration for module lifecycle.
2037
+ * Defines expected provider initialization order.
2038
+ *
2039
+ * @example
2040
+ * ```typescript
2041
+ * const test: ModuleLifecycleTest = {
2042
+ * name: 'AppModule lifecycle',
2043
+ * Module: AppModule,
2044
+ * providers: [ // providers with lifecycle],
2045
+ * expectedInitOrder: ['DatabaseProvider', 'CacheProvider'],
2046
+ * expectedDestroyOrder: ['CacheProvider', 'DatabaseProvider']
2047
+ * };
2048
+ * ```
2049
+ */
1314
2050
  export interface ModuleLifecycleTest {
1315
2051
  name: string;
1316
2052
  Module: new (...args: unknown[]) => unknown;
@@ -1318,6 +2054,21 @@ export interface ModuleLifecycleTest {
1318
2054
  expectedInitOrder: string[];
1319
2055
  expectedDestroyOrder: string[];
1320
2056
  }
2057
+ /**
2058
+ * Test configuration for application lifecycle.
2059
+ * Defines expected startup and shutdown sequences.
2060
+ *
2061
+ * @example
2062
+ * ```typescript
2063
+ * const test: ApplicationLifecycleTest = {
2064
+ * name: 'Application lifecycle',
2065
+ * app: applicationInstance,
2066
+ * modules: [CoreModule, AuthModule],
2067
+ * expectedStartupSequence: ['CoreModule', 'AuthModule'],
2068
+ * expectedShutdownSequence: ['AuthModule', 'CoreModule']
2069
+ * };
2070
+ * ```
2071
+ */
1321
2072
  export interface ApplicationLifecycleTest {
1322
2073
  name: string;
1323
2074
  app: Record<string, unknown>;
@@ -1352,9 +2103,38 @@ export interface TestSuiteConfig<T> {
1352
2103
  teardownAfterEach?: () => void | Promise<void>;
1353
2104
  teardownAfterAll?: () => void | Promise<void>;
1354
2105
  }
2106
+ /**
2107
+ * Environment configuration for testing.
2108
+ * Maps environment variable names to values.
2109
+ *
2110
+ * @example
2111
+ * ```typescript
2112
+ * const config: EnvironmentConfig = {
2113
+ * NODE_ENV: 'test',
2114
+ * DATABASE_URL: 'postgres://localhost/test',
2115
+ * API_KEY: 'test-api-key'
2116
+ * };
2117
+ * ```
2118
+ */
1355
2119
  export interface EnvironmentConfig {
1356
2120
  [key: string]: string | undefined;
1357
2121
  }
2122
+ /**
2123
+ * Options for testing CSS animations.
2124
+ * Configures animation properties and behavior.
2125
+ *
2126
+ * @example
2127
+ * ```typescript
2128
+ * const options: AnimationTestOptions = {
2129
+ * duration: 1000,
2130
+ * easing: 'ease-in-out',
2131
+ * delay: 200,
2132
+ * iterations: 2,
2133
+ * direction: 'alternate',
2134
+ * fillMode: 'forwards'
2135
+ * };
2136
+ * ```
2137
+ */
1358
2138
  export interface AnimationTestOptions {
1359
2139
  duration?: number;
1360
2140
  easing?: string;
@@ -1363,12 +2143,41 @@ export interface AnimationTestOptions {
1363
2143
  direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
1364
2144
  fillMode?: 'none' | 'forwards' | 'backwards' | 'both';
1365
2145
  }
2146
+ /**
2147
+ * Options for testing CSS transitions.
2148
+ * Configures transition properties and timing.
2149
+ *
2150
+ * @example
2151
+ * ```typescript
2152
+ * const options: TransitionTestOptions = {
2153
+ * property: 'transform',
2154
+ * duration: 300,
2155
+ * timingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
2156
+ * delay: 50
2157
+ * };
2158
+ * ```
2159
+ */
1366
2160
  export interface TransitionTestOptions {
1367
2161
  property?: string;
1368
2162
  duration?: number;
1369
2163
  timingFunction?: string;
1370
2164
  delay?: number;
1371
2165
  }
2166
+ /**
2167
+ * Keyframe test configuration.
2168
+ * Defines styles at specific animation percentage.
2169
+ *
2170
+ * @example
2171
+ * ```typescript
2172
+ * const keyframe: KeyframeTest = {
2173
+ * percentage: 50,
2174
+ * styles: {
2175
+ * opacity: '0.5',
2176
+ * transform: 'scale(1.2)'
2177
+ * }
2178
+ * };
2179
+ * ```
2180
+ */
1372
2181
  export interface KeyframeTest {
1373
2182
  percentage: number;
1374
2183
  styles: Record<string, string>;
@@ -1399,12 +2208,44 @@ export interface AnimationSequence {
1399
2208
  easing?: string;
1400
2209
  }>;
1401
2210
  }
2211
+ /**
2212
+ * Test case for environment-specific behavior.
2213
+ * Defines environment setup and expected behavior.
2214
+ *
2215
+ * @example
2216
+ * ```typescript
2217
+ * const testCase: EnvironmentTestCase = {
2218
+ * name: 'Production environment',
2219
+ * environment: { NODE_ENV: 'production' },
2220
+ * expectedBehavior: async () => {
2221
+ * expect(logger.level).toBe('error');
2222
+ * },
2223
+ * cleanup: async () => { process.env.NODE_ENV = 'test'; }
2224
+ * };
2225
+ * ```
2226
+ */
1402
2227
  export interface EnvironmentTestCase {
1403
2228
  name: string;
1404
2229
  environment: EnvironmentConfig;
1405
2230
  expectedBehavior: () => void | Promise<void>;
1406
2231
  cleanup?: () => void | Promise<void>;
1407
2232
  }
2233
+ /**
2234
+ * Configuration test scenario.
2235
+ * Defines config values and expected results.
2236
+ *
2237
+ * @example
2238
+ * ```typescript
2239
+ * const scenario: ConfigTestScenario = {
2240
+ * name: 'Invalid database config',
2241
+ * config: { database: { host: '' } },
2242
+ * environment: { DB_HOST: '' },
2243
+ * expectedValues: {},
2244
+ * shouldThrow: true,
2245
+ * expectedError: /Database host is required/
2246
+ * };
2247
+ * ```
2248
+ */
1408
2249
  export interface ConfigTestScenario {
1409
2250
  name: string;
1410
2251
  config: Record<string, unknown>;
@@ -1413,35 +2254,139 @@ export interface ConfigTestScenario {
1413
2254
  shouldThrow?: boolean;
1414
2255
  expectedError?: string | RegExp;
1415
2256
  }
2257
+ /**
2258
+ * Spring animation configuration.
2259
+ * Defines physical properties for spring animations.
2260
+ *
2261
+ * @example
2262
+ * ```typescript
2263
+ * const spring: SpringConfig = {
2264
+ * tension: 170,
2265
+ * friction: 26,
2266
+ * mass: 1
2267
+ * };
2268
+ * ```
2269
+ */
1416
2270
  export interface SpringConfig {
1417
2271
  tension: number;
1418
2272
  friction: number;
1419
2273
  mass: number;
1420
2274
  }
2275
+ /**
2276
+ * RequestAnimationFrame callback wrapper.
2277
+ * Stores callback ID and function reference.
2278
+ *
2279
+ * @example
2280
+ * ```typescript
2281
+ * const rafCallback: RAFCallback = {
2282
+ * id: 1,
2283
+ * callback: (timestamp) => { // animation logic }
2284
+ * };
2285
+ * ```
2286
+ */
1421
2287
  export interface RAFCallback {
1422
2288
  id: number;
1423
2289
  callback: FrameRequestCallback;
1424
2290
  }
2291
+ /**
2292
+ * Loading state interface.
2293
+ * Represents loading status in async operations.
2294
+ *
2295
+ * @example
2296
+ * ```typescript
2297
+ * const state: LoadingState = {
2298
+ * isLoading: true,
2299
+ * loading: true
2300
+ * };
2301
+ * ```
2302
+ */
1425
2303
  export interface LoadingState {
1426
2304
  isLoading?: boolean;
1427
2305
  loading?: boolean;
1428
2306
  }
2307
+ /**
2308
+ * Options for text waiting utilities.
2309
+ * Configures timeout for text appearance.
2310
+ *
2311
+ * @example
2312
+ * ```typescript
2313
+ * const options: ForTextOptions = {
2314
+ * timeout: 3000 // Wait up to 3 seconds
2315
+ * };
2316
+ * ```
2317
+ */
1429
2318
  export interface ForTextOptions {
1430
2319
  timeout?: number;
1431
2320
  }
2321
+ /**
2322
+ * Test value with index wrapper.
2323
+ * Associates test values with their position.
2324
+ *
2325
+ * @template T - Type of test value
2326
+ *
2327
+ * @example
2328
+ * ```typescript
2329
+ * const testValue: TestValueWithIndex<string> = {
2330
+ * value: 'test-data',
2331
+ * index: 2
2332
+ * };
2333
+ * ```
2334
+ */
1432
2335
  export interface TestValueWithIndex<T> {
1433
2336
  value: T;
1434
2337
  index: number;
1435
2338
  }
2339
+ /**
2340
+ * Record of a function call.
2341
+ * Tracks method name, arguments, and timestamp.
2342
+ *
2343
+ * @example
2344
+ * ```typescript
2345
+ * const call: CallRecord = {
2346
+ * method: 'saveUser',
2347
+ * args: [{ id: 1, name: 'John' }],
2348
+ * timestamp: Date.now()
2349
+ * };
2350
+ * ```
2351
+ */
1436
2352
  export interface CallRecord {
1437
2353
  method: string;
1438
2354
  args: unknown[];
1439
2355
  timestamp: number;
1440
2356
  }
2357
+ /**
2358
+ * Module spy for tracking calls.
2359
+ * Wraps module with call tracking.
2360
+ *
2361
+ * @template T - Type of module being spied on
2362
+ *
2363
+ * @example
2364
+ * ```typescript
2365
+ * const spy: ModuleSpy<UserService> = {
2366
+ * module: userService,
2367
+ * calls: [...tracked calls]
2368
+ * };
2369
+ * ```
2370
+ */
1441
2371
  export interface ModuleSpy<T> {
1442
2372
  module: T;
1443
2373
  calls: CallRecord[];
1444
2374
  }
2375
+ /**
2376
+ * Named test case for table-driven tests.
2377
+ * Associates name with input and expected output.
2378
+ *
2379
+ * @template T - Type of test input
2380
+ *
2381
+ * @example
2382
+ * ```typescript
2383
+ * const testCase: NamedTestCase<number> = {
2384
+ * name: 'handles negative numbers',
2385
+ * input: -5,
2386
+ * expected: 5
2387
+ * };
2388
+ * ```
2389
+ */
1445
2390
  export interface NamedTestCase<T> {
1446
2391
  name: string;
1447
2392
  input: T;
@@ -1610,6 +2555,19 @@ export interface MiddlewareTestScenarioWithRequest {
1610
2555
  status?: number;
1611
2556
  };
1612
2557
  }
2558
+ /**
2559
+ * API route handler methods for Next.js.
2560
+ * Maps HTTP methods to handler functions.
2561
+ *
2562
+ * @example
2563
+ * ```typescript
2564
+ * const handlers: ApiRouteHandlerMethods = {
2565
+ * GET: async (req, res) => res.json({ users: [] }),
2566
+ * POST: async (req, res) => res.status(201).json({ id: 1 }),
2567
+ * DELETE: async (req, res) => res.status(204).end()
2568
+ * };
2569
+ * ```
2570
+ */
1613
2571
  export interface ApiRouteHandlerMethods {
1614
2572
  GET?: Function;
1615
2573
  POST?: Function;
@@ -1617,106 +2575,422 @@ export interface ApiRouteHandlerMethods {
1617
2575
  DELETE?: Function;
1618
2576
  PATCH?: Function;
1619
2577
  }
2578
+ /**
2579
+ * Test scenario for route handlers.
2580
+ * Defines request method and expected response.
2581
+ *
2582
+ * @example
2583
+ * ```typescript
2584
+ * const scenario: RouteHandlerTestScenario = {
2585
+ * method: 'POST',
2586
+ * request: [{ url: '/api/users', body: { name: 'John' } }],
2587
+ * expectedStatus: 201,
2588
+ * expectedBody: { id: 1, name: 'John' }
2589
+ * };
2590
+ * ```
2591
+ */
1620
2592
  export interface RouteHandlerTestScenario {
1621
2593
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
1622
2594
  request: Parameters<CreateMockNextRequestFunction>;
1623
2595
  expectedStatus: number;
1624
2596
  expectedBody?: unknown;
1625
2597
  }
2598
+ /**
2599
+ * Test scenario for image loader.
2600
+ * Defines input parameters and expected URL.
2601
+ *
2602
+ * @example
2603
+ * ```typescript
2604
+ * const scenario: ImageLoaderTestScenario = {
2605
+ * input: { src: '/img.jpg', width: 800, quality: 75 },
2606
+ * expectedUrl: '/_next/image?url=%2Fimg.jpg&w=800&q=75'
2607
+ * };
2608
+ * ```
2609
+ */
1626
2610
  export interface ImageLoaderTestScenario {
1627
2611
  input: ImageLoaderInput;
1628
2612
  expectedUrl: string | RegExp;
1629
2613
  }
2614
+ /**
2615
+ * Parameterized test runner.
2616
+ * Provides method to run tests with different inputs.
2617
+ *
2618
+ * @template T - Type of test input
2619
+ *
2620
+ * @example
2621
+ * ```typescript
2622
+ * const paramTest: ParameterizedTest<number> = {
2623
+ * test: (name, fn) => {
2624
+ * test(name, () => fn(5, 10));
2625
+ * }
2626
+ * };
2627
+ * ```
2628
+ */
1630
2629
  export interface ParameterizedTest<T> {
1631
2630
  test: (name: string, fn: (input: T, expected: unknown) => void | Promise<void>) => void;
1632
2631
  }
2632
+ /**
2633
+ * Test suite for service testing.
2634
+ * Provides methods for testing service behavior.
2635
+ *
2636
+ * @template T - Type of service being tested
2637
+ *
2638
+ * @example
2639
+ * ```typescript
2640
+ * const suite: ServiceTestSuite<UserService> = {
2641
+ * testMethods: () => { // test service methods },
2642
+ * testErrorHandling: (scenarios) => { // test error cases }
2643
+ * };
2644
+ * ```
2645
+ */
1633
2646
  export interface ServiceTestSuite<T> {
1634
2647
  testMethods: () => void;
1635
2648
  testErrorHandling: (errorScenarios: Array<ErrorScenario<T>>) => void;
1636
2649
  }
2650
+ /**
2651
+ * Test suite for NestJS applications.
2652
+ * Provides methods for testing providers and injection.
2653
+ *
2654
+ * @example
2655
+ * ```typescript
2656
+ * const suite: NestJSTestSuiteReturn = {
2657
+ * testProviderRegistration: (tokens) => { // test providers },
2658
+ * testProviderInjection: (tests) => { // test DI }
2659
+ * };
2660
+ * ```
2661
+ */
1637
2662
  export interface NestJSTestSuiteReturn {
1638
2663
  testProviderRegistration: (providerTokens: unknown[]) => void;
1639
2664
  testProviderInjection: (injectionTests: Array<ProviderInjectionTest>) => void;
1640
2665
  }
2666
+ /**
2667
+ * Test suite for Next.js pages.
2668
+ * Provides methods for testing SSG, SSR, and rendering.
2669
+ *
2670
+ * @example
2671
+ * ```typescript
2672
+ * const suite: NextJSTestSuite = {
2673
+ * testStaticGeneration: (getStaticProps, getStaticPaths) => { // test SSG },
2674
+ * testServerSideRendering: (getServerSideProps) => { // test SSR },
2675
+ * testPageRendering: (scenarios) => { // test rendering }
2676
+ * };
2677
+ * ```
2678
+ */
1641
2679
  export interface NextJSTestSuite {
1642
2680
  testStaticGeneration: (getStaticProps?: Function, getStaticPaths?: Function) => void;
1643
2681
  testServerSideRendering: (getServerSideProps?: Function) => void;
1644
2682
  testPageRendering: (scenarios: Array<PropsTestScenario>) => void;
1645
2683
  }
2684
+ /**
2685
+ * Factory for creating test suites.
2686
+ * Provides methods for various test patterns.
2687
+ *
2688
+ * @template T - Type of object being tested
2689
+ *
2690
+ * @example
2691
+ * ```typescript
2692
+ * const factory: TestSuiteFactory<Calculator> = {
2693
+ * runScenarios: (scenarios) => { // run test scenarios },
2694
+ * testMethod: (method, cases) => { // test specific method },
2695
+ * testLifecycle: (hooks) => { // test lifecycle },
2696
+ * testErrorHandling: (errors) => { // test errors }
2697
+ * };
2698
+ * ```
2699
+ */
1646
2700
  export interface TestSuiteFactory<T extends UnknownRecord> {
1647
2701
  runScenarios: (scenarios: TestScenario<T, unknown, unknown>[]) => void;
1648
2702
  testMethod: (methodName: keyof T, testCases: Array<TestCaseWithSetup<T>>) => void;
1649
2703
  testLifecycle: (lifecycleHooks: Array<LifecycleHookTestConfig<T>>) => void;
1650
2704
  testErrorHandling: (errorScenarios: Array<ErrorHandlingScenario<T>>) => void;
1651
2705
  }
2706
+ /**
2707
+ * Conditional behavior for mocks.
2708
+ * Returns different results based on predicate.
2709
+ *
2710
+ * @template T - Type of mock return value
2711
+ *
2712
+ * @example
2713
+ * ```typescript
2714
+ * const behavior: ConditionalMockBehavior<string> = {
2715
+ * predicate: (id) => id === 'admin',
2716
+ * result: 'admin-response'
2717
+ * };
2718
+ * ```
2719
+ */
1652
2720
  export interface ConditionalMockBehavior<T> {
1653
2721
  predicate: (...args: unknown[]) => boolean;
1654
2722
  result: T | (() => T);
1655
2723
  }
2724
+ /**
2725
+ * Result from mocking a module.
2726
+ * Provides unmock function for cleanup.
2727
+ *
2728
+ * @example
2729
+ * ```typescript
2730
+ * const mockResult: MockModuleResult = mockModule('fs');
2731
+ * // Use mocked module
2732
+ * mockResult.unmock(); // Restore original
2733
+ * ```
2734
+ */
1656
2735
  export interface MockModuleResult {
1657
2736
  unmock: () => void;
1658
2737
  }
2738
+ /**
2739
+ * Result from mocking multiple modules.
2740
+ * Provides function to unmock all.
2741
+ *
2742
+ * @example
2743
+ * ```typescript
2744
+ * const result: MockManyResult = mockMany(['fs', 'path']);
2745
+ * // Use mocked modules
2746
+ * result.unmockAll(); // Restore all
2747
+ * ```
2748
+ */
1659
2749
  export interface MockManyResult {
1660
2750
  unmockAll: () => void;
1661
2751
  }
2752
+ /**
2753
+ * Result from route matching.
2754
+ * Contains extracted params and match status.
2755
+ *
2756
+ * @example
2757
+ * ```typescript
2758
+ * const result: RouteMatchResult = {
2759
+ * params: { id: '123', slug: 'post-title' },
2760
+ * isMatch: true
2761
+ * };
2762
+ * ```
2763
+ */
1662
2764
  export interface RouteMatchResult {
1663
2765
  params: Record<string, string | string[]>;
1664
2766
  isMatch: boolean;
1665
2767
  }
2768
+ /**
2769
+ * Performance entry with metrics.
2770
+ * Contains name and performance data.
2771
+ *
2772
+ * @example
2773
+ * ```typescript
2774
+ * const entry: PerformanceEntryResult = {
2775
+ * name: 'api-call',
2776
+ * metrics: { mean: 50, median: 45, p95: 100 }
2777
+ * };
2778
+ * ```
2779
+ */
1666
2780
  export interface PerformanceEntryResult {
1667
2781
  name: string;
1668
2782
  metrics: PerformanceMetrics;
1669
2783
  }
2784
+ /**
2785
+ * Result from memory measurement.
2786
+ * Contains memory data and function result.
2787
+ *
2788
+ * @template T - Type of function result
2789
+ *
2790
+ * @example
2791
+ * ```typescript
2792
+ * const result: MemoryMeasurementResult<string[]> = {
2793
+ * measurement: { before: 1000, after: 2000, delta: 1000, peak: 2500 },
2794
+ * result: ['item1', 'item2']
2795
+ * };
2796
+ * ```
2797
+ */
1670
2798
  export interface MemoryMeasurementResult<T> {
1671
2799
  measurement: MemoryMeasurement;
1672
2800
  result: T;
1673
2801
  }
2802
+ /**
2803
+ * Global object with garbage collection.
2804
+ * Provides manual GC trigger for testing.
2805
+ *
2806
+ * @example
2807
+ * ```typescript
2808
+ * const global: GlobalWithGC = globalThis as GlobalWithGC;
2809
+ * if (global.gc) {
2810
+ * global.gc(); // Force garbage collection
2811
+ * }
2812
+ * ```
2813
+ */
1674
2814
  export interface GlobalWithGC {
1675
2815
  gc?: () => void;
1676
2816
  }
2817
+ /**
2818
+ * Result from memory leak testing.
2819
+ * Contains memory usage before and after.
2820
+ *
2821
+ * @example
2822
+ * ```typescript
2823
+ * const result: MemoryLeakTestResult = {
2824
+ * initialMemory: 50000000,
2825
+ * finalMemory: 55000000,
2826
+ * memoryIncrease: 5000000,
2827
+ * iterations: 1000
2828
+ * };
2829
+ * ```
2830
+ */
1677
2831
  export interface MemoryLeakTestResult {
1678
2832
  initialMemory: number;
1679
2833
  finalMemory: number;
1680
2834
  memoryIncrease: number;
1681
2835
  iterations: number;
1682
2836
  }
2837
+ /**
2838
+ * Property variation for component testing.
2839
+ * Defines props and expected behavior.
2840
+ *
2841
+ * @example
2842
+ * ```typescript
2843
+ * const variation: PropVariation = {
2844
+ * name: 'with loading state',
2845
+ * props: { isLoading: true },
2846
+ * expectation: () => expect(screen.getByTestId('spinner')).toBeVisible()
2847
+ * };
2848
+ * ```
2849
+ */
1683
2850
  export interface PropVariation {
1684
2851
  name: string;
1685
2852
  props: Record<string, unknown>;
1686
2853
  expectation: () => void;
1687
2854
  }
2855
+ /**
2856
+ * Valid input test case.
2857
+ * Defines input that should succeed.
2858
+ *
2859
+ * @template T - Type of expected result
2860
+ *
2861
+ * @example
2862
+ * ```typescript
2863
+ * const testCase: ValidTestCase<User> = {
2864
+ * name: 'valid email format',
2865
+ * input: 'user@example.com',
2866
+ * expected: { email: 'user@example.com', valid: true }
2867
+ * };
2868
+ * ```
2869
+ */
1688
2870
  export interface ValidTestCase<T> {
1689
2871
  name: string;
1690
2872
  input: unknown;
1691
2873
  expected?: T;
1692
2874
  }
2875
+ /**
2876
+ * Invalid input test case.
2877
+ * Defines input that should fail with error.
2878
+ *
2879
+ * @example
2880
+ * ```typescript
2881
+ * const testCase: InvalidTestCase = {
2882
+ * name: 'invalid email format',
2883
+ * input: 'not-an-email',
2884
+ * expectedError: /Invalid email format/
2885
+ * };
2886
+ * ```
2887
+ */
1693
2888
  export interface InvalidTestCase {
1694
2889
  name: string;
1695
2890
  input: unknown;
1696
2891
  expectedError: string | RegExp;
1697
2892
  }
2893
+ /**
2894
+ * Created resource for cleanup tracking.
2895
+ * Stores resource reference and name.
2896
+ *
2897
+ * @example
2898
+ * ```typescript
2899
+ * const resource: CreatedResource = {
2900
+ * name: 'test-database',
2901
+ * resource: dbConnection
2902
+ * };
2903
+ * ```
2904
+ */
1698
2905
  export interface CreatedResource {
1699
2906
  name: string;
1700
2907
  resource: unknown;
1701
2908
  }
2909
+ /**
2910
+ * Record of lifecycle hook execution.
2911
+ * Tracks phase, method, and timestamp.
2912
+ *
2913
+ * @example
2914
+ * ```typescript
2915
+ * const record: LifecycleHookRecord = {
2916
+ * phase: 'mount',
2917
+ * method: 'componentDidMount',
2918
+ * timestamp: Date.now()
2919
+ * };
2920
+ * ```
2921
+ */
1702
2922
  export interface LifecycleHookRecord {
1703
2923
  phase: string;
1704
2924
  method: string;
1705
2925
  timestamp: number;
1706
2926
  }
2927
+ /**
2928
+ * Test case for path matching.
2929
+ * Defines path and expected match result.
2930
+ *
2931
+ * @example
2932
+ * ```typescript
2933
+ * const test: PathMatchTest = {
2934
+ * path: '/users/123',
2935
+ * shouldMatch: true
2936
+ * };
2937
+ * ```
2938
+ */
1707
2939
  export interface PathMatchTest {
1708
2940
  path: string;
1709
2941
  shouldMatch: boolean;
1710
2942
  }
2943
+ /**
2944
+ * Error scenario for service testing.
2945
+ * Defines setup and expected error.
2946
+ *
2947
+ * @template T - Type of service being tested
2948
+ *
2949
+ * @example
2950
+ * ```typescript
2951
+ * const scenario: ErrorScenario<UserService> = {
2952
+ * method: 'createUser',
2953
+ * setup: (service) => vi.spyOn(db, 'save').mockRejectedValue(new Error()),
2954
+ * expectedError: 'Database error'
2955
+ * };
2956
+ * ```
2957
+ */
1711
2958
  export interface ErrorScenario<T> {
1712
2959
  method: string;
1713
2960
  setup: (service: T) => void;
1714
2961
  expectedError: unknown;
1715
2962
  }
2963
+ /**
2964
+ * Test scenario for component props.
2965
+ * Defines props and expected content.
2966
+ *
2967
+ * @example
2968
+ * ```typescript
2969
+ * const scenario: PropsTestScenario = {
2970
+ * props: { title: 'Hello', isActive: true },
2971
+ * expectedContent: 'Hello - Active'
2972
+ * };
2973
+ * ```
2974
+ */
1716
2975
  export interface PropsTestScenario {
1717
2976
  props: Record<string, unknown>;
1718
2977
  expectedContent?: string;
1719
2978
  }
2979
+ /**
2980
+ * Responsive breakpoint test configuration.
2981
+ * Defines viewport size and expectations.
2982
+ *
2983
+ * @example
2984
+ * ```typescript
2985
+ * const breakpoint: ResponsiveBreakpoint = {
2986
+ * width: 768,
2987
+ * height: 1024,
2988
+ * expectations: () => {
2989
+ * expect(screen.getByTestId('mobile-menu')).toBeVisible();
2990
+ * }
2991
+ * };
2992
+ * ```
2993
+ */
1720
2994
  export interface ResponsiveBreakpoint {
1721
2995
  width: number;
1722
2996
  height: number;
@@ -1725,6 +2999,18 @@ export interface ResponsiveBreakpoint {
1725
2999
  export type TestCombination<T extends Record<string, unknown[]>> = {
1726
3000
  [K in keyof T]: T[K][number];
1727
3001
  };
3002
+ /**
3003
+ * Test dependency configuration.
3004
+ * Maps token to test value.
3005
+ *
3006
+ * @example
3007
+ * ```typescript
3008
+ * const dependency: TestDependency = {
3009
+ * token: DatabaseService,
3010
+ * value: mockDatabaseService
3011
+ * };
3012
+ * ```
3013
+ */
1728
3014
  export interface TestDependency {
1729
3015
  token: unknown;
1730
3016
  value: unknown;
@@ -1763,12 +3049,43 @@ export interface TableTestCase<TInput, TExpected> {
1763
3049
  only?: boolean;
1764
3050
  error?: boolean;
1765
3051
  }
3052
+ /**
3053
+ * Edge case test definition.
3054
+ * Tests boundary conditions and edge cases.
3055
+ *
3056
+ * @template T - Type of input
3057
+ * @template R - Type of expected result
3058
+ *
3059
+ * @example
3060
+ * ```typescript
3061
+ * const test: EdgeCaseTest<number, string> = {
3062
+ * name: 'handles MAX_SAFE_INTEGER',
3063
+ * input: Number.MAX_SAFE_INTEGER,
3064
+ * expected: '9007199254740991'
3065
+ * };
3066
+ * ```
3067
+ */
1766
3068
  export interface EdgeCaseTest<T, R> {
1767
3069
  name: string;
1768
3070
  input: T;
1769
3071
  expected?: R;
1770
3072
  shouldThrow?: string | RegExp | Error;
1771
3073
  }
3074
+ /**
3075
+ * Metrics for animation performance.
3076
+ * Contains frame time statistics.
3077
+ *
3078
+ * @example
3079
+ * ```typescript
3080
+ * const metrics: AnimationPerformanceMetrics = {
3081
+ * avgFrameTime: 16.67,
3082
+ * avgFPS: 60,
3083
+ * maxFrameTime: 33,
3084
+ * minFrameTime: 8,
3085
+ * frameTimes: [16, 17, 16, 33, 8]
3086
+ * };
3087
+ * ```
3088
+ */
1772
3089
  export interface AnimationPerformanceMetrics {
1773
3090
  avgFrameTime: number;
1774
3091
  avgFPS: number;
@@ -1776,6 +3093,19 @@ export interface AnimationPerformanceMetrics {
1776
3093
  minFrameTime: number;
1777
3094
  frameTimes: number[];
1778
3095
  }
3096
+ /**
3097
+ * Options for animation performance testing.
3098
+ * Configures iterations and thresholds.
3099
+ *
3100
+ * @example
3101
+ * ```typescript
3102
+ * const options: AnimationPerformanceOptions = {
3103
+ * iterations: 100,
3104
+ * maxFrameTime: 33, // 30 FPS minimum
3105
+ * minFPS: 30
3106
+ * };
3107
+ * ```
3108
+ */
1779
3109
  export interface AnimationPerformanceOptions {
1780
3110
  iterations?: number;
1781
3111
  maxFrameTime?: number;
@@ -1796,6 +3126,23 @@ export type StaticPropsResult<T> = {
1796
3126
  } | {
1797
3127
  notFound: true;
1798
3128
  };
3129
+ /**
3130
+ * Test result for getServerSideProps.
3131
+ * Contains result and assertion helpers.
3132
+ *
3133
+ * @template T - Type of props
3134
+ *
3135
+ * @example
3136
+ * ```typescript
3137
+ * const result: ServerSidePropsTestResult<PageProps> = {
3138
+ * result: { props: { user: { id: 1 } } },
3139
+ * context: mockContext,
3140
+ * expectProps: (props) => expect(props).toMatchObject({ user: { id: 1 } }),
3141
+ * expectRedirect: (dest) => expect(result.redirect).toBe(dest),
3142
+ * expectNotFound: () => expect(result.notFound).toBe(true)
3143
+ * };
3144
+ * ```
3145
+ */
1799
3146
  export interface ServerSidePropsTestResult<T> {
1800
3147
  result: ServerSidePropsResult<T>;
1801
3148
  context: MockGetServerSidePropsContext;
@@ -1803,6 +3150,23 @@ export interface ServerSidePropsTestResult<T> {
1803
3150
  expectRedirect: (destination: string, permanent?: boolean) => void;
1804
3151
  expectNotFound: () => void;
1805
3152
  }
3153
+ /**
3154
+ * Test result for getStaticProps.
3155
+ * Contains result and assertion helpers.
3156
+ *
3157
+ * @template T - Type of props
3158
+ *
3159
+ * @example
3160
+ * ```typescript
3161
+ * const result: StaticPropsTestResult<PageProps> = {
3162
+ * result: { props: { posts: [] }, revalidate: 60 },
3163
+ * context: mockContext,
3164
+ * expectProps: (props) => expect(props.posts).toHaveLength(0),
3165
+ * expectRevalidate: (seconds) => expect(result.revalidate).toBe(seconds),
3166
+ * expectNotFound: () => expect(result.notFound).toBe(true)
3167
+ * };
3168
+ * ```
3169
+ */
1806
3170
  export interface StaticPropsTestResult<T> {
1807
3171
  result: StaticPropsResult<T>;
1808
3172
  context: MockGetStaticPropsContext;
@@ -1811,27 +3175,103 @@ export interface StaticPropsTestResult<T> {
1811
3175
  expectNotFound: () => void;
1812
3176
  expectRevalidate: (seconds: number) => void;
1813
3177
  }
3178
+ /**
3179
+ * Custom query methods for testing.
3180
+ * Provides additional DOM query functions.
3181
+ *
3182
+ * @example
3183
+ * ```typescript
3184
+ * const queries: CreateCustomQueriesReturn = {
3185
+ * getByClassName: (name) => container.querySelector(`.${name}`),
3186
+ * getAllByClassName: (name) => Array.from(container.querySelectorAll(`.${name}`)),
3187
+ * getByAttribute: (attr, value) => container.querySelector(`[${attr}="${value}"]`)
3188
+ * };
3189
+ * ```
3190
+ */
1814
3191
  export interface CreateCustomQueriesReturn {
1815
3192
  getByClassName: (className: string) => HTMLElement;
1816
3193
  getAllByClassName: (className: string) => HTMLElement[];
1817
3194
  getByAttribute: (attribute: string, value?: string) => HTMLElement;
1818
3195
  }
3196
+ /**
3197
+ * Boundary value test case.
3198
+ * Tests edge values and boundaries.
3199
+ *
3200
+ * @template T - Type of boundary value
3201
+ *
3202
+ * @example
3203
+ * ```typescript
3204
+ * const test: BoundaryValueTest<number> = {
3205
+ * value: 0,
3206
+ * description: 'minimum value',
3207
+ * expected: 'zero'
3208
+ * };
3209
+ * ```
3210
+ */
1819
3211
  export interface BoundaryValueTest<T> {
1820
3212
  value: T;
1821
3213
  description: string;
1822
3214
  expected: unknown;
1823
3215
  }
3216
+ /**
3217
+ * Equivalence class test case.
3218
+ * Tests multiple inputs with same expected result.
3219
+ *
3220
+ * @template T - Type of input samples
3221
+ * @template R - Type of expected result
3222
+ *
3223
+ * @example
3224
+ * ```typescript
3225
+ * const test: EquivalenceClassTest<string, boolean> = {
3226
+ * name: 'valid emails',
3227
+ * samples: ['user@example.com', 'test@domain.org'],
3228
+ * expected: true
3229
+ * };
3230
+ * ```
3231
+ */
1824
3232
  export interface EquivalenceClassTest<T, R> {
1825
3233
  name: string;
1826
3234
  samples: T[];
1827
3235
  expected: R;
1828
3236
  }
3237
+ /**
3238
+ * State transition test case.
3239
+ * Defines state change from action.
3240
+ *
3241
+ * @template TState - Type of state
3242
+ * @template TAction - Type of action
3243
+ *
3244
+ * @example
3245
+ * ```typescript
3246
+ * const test: StateTransitionTest<LoadingState, Action> = {
3247
+ * from: { status: 'idle' },
3248
+ * action: { type: 'FETCH_START' },
3249
+ * to: { status: 'loading' },
3250
+ * description: 'starts loading on fetch'
3251
+ * };
3252
+ * ```
3253
+ */
1829
3254
  export interface StateTransitionTest<TState, TAction> {
1830
3255
  from: TState;
1831
3256
  action: TAction;
1832
3257
  to: TState;
1833
3258
  description?: string;
1834
3259
  }
3260
+ /**
3261
+ * Snapshot test case configuration.
3262
+ * Defines input for snapshot testing.
3263
+ *
3264
+ * @template T - Type of input
3265
+ *
3266
+ * @example
3267
+ * ```typescript
3268
+ * const test: SnapshotTestCase<ComponentProps> = {
3269
+ * name: 'default state',
3270
+ * input: { title: 'Test', isActive: false },
3271
+ * transform: (input) => renderComponent(input)
3272
+ * };
3273
+ * ```
3274
+ */
1835
3275
  export interface SnapshotTestCase<T> {
1836
3276
  name: string;
1837
3277
  input: T;
@@ -2035,9 +3475,38 @@ export interface ServerComponentTestScenario {
2035
3475
  params?: Record<string, string>;
2036
3476
  expectedContent?: string | RegExp;
2037
3477
  }
3478
+ /**
3479
+ * Configuration for middleware path matching.
3480
+ * Defines which paths the middleware applies to.
3481
+ *
3482
+ * @example
3483
+ * ```typescript
3484
+ * const config: MiddlewareMatcherConfig = {
3485
+ * matcher: ['/api/:path*', '/admin/:path*']
3486
+ * };
3487
+ * ```
3488
+ */
2038
3489
  export interface MiddlewareMatcherConfig {
2039
3490
  matcher: string | string[];
2040
3491
  }
3492
+ /**
3493
+ * Result from mocking Next.js navigation.
3494
+ * Contains navigation methods and restore function.
3495
+ *
3496
+ * @example
3497
+ * ```typescript
3498
+ * const mockNav: MockNextNavigationResult = {
3499
+ * navigation: {
3500
+ * push: vi.fn(),
3501
+ * replace: vi.fn(),
3502
+ * refresh: vi.fn(),
3503
+ * back: vi.fn(),
3504
+ * forward: vi.fn()
3505
+ * },
3506
+ * restore: () => { // restore original }
3507
+ * };
3508
+ * ```
3509
+ */
2041
3510
  export interface MockNextNavigationResult {
2042
3511
  navigation: {
2043
3512
  push: ReturnType<typeof Vitest.vi.fn>;
@@ -2048,35 +3517,126 @@ export interface MockNextNavigationResult {
2048
3517
  };
2049
3518
  restore: () => void;
2050
3519
  }
3520
+ /**
3521
+ * Options for creating test harness.
3522
+ * Configures instance creation and dependencies.
3523
+ *
3524
+ * @template TOptions - Type of options for creation
3525
+ *
3526
+ * @example
3527
+ * ```typescript
3528
+ * const options: TestHarnessOptions<ServiceOptions> = {
3529
+ * create: (deps, opts) => new Service(deps, opts),
3530
+ * dependencies: [{ token: 'DB', value: mockDb }]
3531
+ * };
3532
+ * ```
3533
+ */
2051
3534
  export interface TestHarnessOptions<TOptions> {
2052
3535
  create: (deps: Map<unknown, unknown>, opts: TOptions) => unknown;
2053
3536
  dependencies?: Array<TestDependency>;
2054
3537
  }
3538
+ /**
3539
+ * Result from test harness creation.
3540
+ * Contains instance and helper methods.
3541
+ *
3542
+ * @template T - Type of instance created
3543
+ *
3544
+ * @example
3545
+ * ```typescript
3546
+ * const harness: TestHarnessResult<UserService> = {
3547
+ * instance: userService,
3548
+ * dependencies: new Map(),
3549
+ * logger: mockLogger,
3550
+ * getDependency: (token) => dependencies.get(token)
3551
+ * };
3552
+ * ```
3553
+ */
2055
3554
  export interface TestHarnessResult<T> {
2056
3555
  instance: T;
2057
3556
  dependencies: Map<unknown, unknown>;
2058
3557
  logger?: unknown;
2059
3558
  getDependency: <U>(token: unknown) => U;
2060
3559
  }
3560
+ /**
3561
+ * Options for mocking console methods.
3562
+ * Controls which console methods to suppress.
3563
+ *
3564
+ * @example
3565
+ * ```typescript
3566
+ * const options: ConsoleMockOptions = {
3567
+ * suppressAll: false,
3568
+ * suppress: ['log', 'debug']
3569
+ * };
3570
+ * ```
3571
+ */
2061
3572
  export interface ConsoleMockOptions {
2062
3573
  suppressAll?: boolean;
2063
3574
  suppress?: Array<'log' | 'error' | 'warn' | 'info' | 'debug'>;
2064
3575
  }
2065
3576
  export type ConsoleMethod = 'log' | 'error' | 'warn' | 'info' | 'debug';
3577
+ /**
3578
+ * Result from hook error handling.
3579
+ * Contains error information if present.
3580
+ *
3581
+ * @example
3582
+ * ```typescript
3583
+ * const result: HookErrorResult = {
3584
+ * error: { message: 'Hook failed to initialize' }
3585
+ * };
3586
+ * ```
3587
+ */
2066
3588
  export interface HookErrorResult {
2067
3589
  error?: {
2068
3590
  message: string;
2069
3591
  };
2070
3592
  }
3593
+ /**
3594
+ * Component with loading state property.
3595
+ * Used for testing loading behavior.
3596
+ *
3597
+ * @example
3598
+ * ```typescript
3599
+ * const component: ComponentWithLoading = {
3600
+ * isLoading: true,
3601
+ * data: null,
3602
+ * error: null
3603
+ * };
3604
+ * ```
3605
+ */
2071
3606
  export interface ComponentWithLoading {
2072
3607
  isLoading?: boolean;
2073
3608
  [key: string]: unknown;
2074
3609
  }
3610
+ /**
3611
+ * Test for conditional rendering logic.
3612
+ * Defines what should and shouldn't render.
3613
+ *
3614
+ * @example
3615
+ * ```typescript
3616
+ * const test: ConditionalRenderingTest = {
3617
+ * props: { isLoggedIn: true, isPremium: false },
3618
+ * shouldRender: ['user-menu', 'logout-button'],
3619
+ * shouldNotRender: ['login-form', 'premium-features']
3620
+ * };
3621
+ * ```
3622
+ */
2075
3623
  export interface ConditionalRenderingTest {
2076
3624
  props: Record<string, unknown>;
2077
3625
  shouldRender: string[];
2078
3626
  shouldNotRender: string[];
2079
3627
  }
3628
+ /**
3629
+ * Configuration for React context provider.
3630
+ * Defines provider component and props.
3631
+ *
3632
+ * @example
3633
+ * ```typescript
3634
+ * const config: ProviderConfig = {
3635
+ * Provider: ThemeProvider,
3636
+ * props: { theme: 'dark', primaryColor: '#007bff' }
3637
+ * };
3638
+ * ```
3639
+ */
2080
3640
  export interface ProviderConfig {
2081
3641
  Provider: React.ComponentType<{
2082
3642
  children: React.ReactNode;
@@ -2084,27 +3644,93 @@ export interface ProviderConfig {
2084
3644
  }>;
2085
3645
  props?: Record<string, unknown>;
2086
3646
  }
3647
+ /**
3648
+ * Test case for user interactions.
3649
+ * Defines action and expected result.
3650
+ *
3651
+ * @example
3652
+ * ```typescript
3653
+ * const test: UserInteractionTest = {
3654
+ * name: 'submits form on button click',
3655
+ * action: async (user) => await user.click(submitButton),
3656
+ * expectation: () => expect(onSubmit).toHaveBeenCalled()
3657
+ * };
3658
+ * ```
3659
+ */
2087
3660
  export interface UserInteractionTest {
2088
3661
  name: string;
2089
3662
  action: (user: unknown) => Promise<void>;
2090
3663
  expectation: () => void;
2091
3664
  }
3665
+ /**
3666
+ * Test for error boundary behavior.
3667
+ * Validates error handling and recovery.
3668
+ *
3669
+ * @example
3670
+ * ```typescript
3671
+ * const test: ErrorBoundaryTest = {
3672
+ * error: new Error('Component crashed'),
3673
+ * expectedMessage: 'Something went wrong',
3674
+ * shouldHaveReset: true
3675
+ * };
3676
+ * ```
3677
+ */
2092
3678
  export interface ErrorBoundaryTest {
2093
3679
  error: Error;
2094
3680
  expectedMessage?: string;
2095
3681
  shouldHaveReset?: boolean;
2096
3682
  }
3683
+ /**
3684
+ * Result from component test suite.
3685
+ * Provides methods for various test types.
3686
+ *
3687
+ * @example
3688
+ * ```typescript
3689
+ * const suite: ComponentTestSuiteResult = {
3690
+ * testRendering: () => { rendering tests },
3691
+ * testUserInteractions: (interactions) => { interaction tests },
3692
+ * testProps: (variations) => { prop tests }
3693
+ * };
3694
+ * ```
3695
+ */
2097
3696
  export interface ComponentTestSuiteResult {
2098
3697
  testRendering: () => void;
2099
3698
  testUserInteractions: (interactions: Array<UserInteractionTest>) => void;
2100
3699
  testProps: (propVariations: Array<PropVariation>) => void;
2101
3700
  }
3701
+ /**
3702
+ * Test for resource cleanup behavior.
3703
+ * Validates proper resource disposal.
3704
+ *
3705
+ * @example
3706
+ * ```typescript
3707
+ * const test: ResourceCleanupTest = {
3708
+ * name: 'database connection cleanup',
3709
+ * create: () => db.connect(),
3710
+ * cleanup: async (conn) => await conn.close(),
3711
+ * isCleanedUp: (conn) => conn.isClosed()
3712
+ * };
3713
+ * ```
3714
+ */
2102
3715
  export interface ResourceCleanupTest {
2103
3716
  name: string;
2104
3717
  create: () => unknown;
2105
3718
  cleanup: (resource: unknown) => Promise<void> | void;
2106
3719
  isCleanedUp: (resource: unknown) => boolean;
2107
3720
  }
3721
+ /**
3722
+ * Container for dependency injection.
3723
+ * Manages service registration and resolution.
3724
+ *
3725
+ * @example
3726
+ * ```typescript
3727
+ * const container: DependencyInjectionContainer = {
3728
+ * register: (token, factory, options) => { // register service },
3729
+ * resolve: (token) => { // resolve service },
3730
+ * dispose: async () => { // cleanup all services }
3731
+ * };
3732
+ * ```
3733
+ */
2108
3734
  export interface DependencyInjectionContainer {
2109
3735
  register: (token: unknown, factory: () => unknown, options: {
2110
3736
  lifecycle: 'singleton' | 'transient' | 'scoped';
@@ -2113,6 +3739,21 @@ export interface DependencyInjectionContainer {
2113
3739
  resolve: (token: unknown) => unknown;
2114
3740
  dispose: () => Promise<void>;
2115
3741
  }
3742
+ /**
3743
+ * Configuration for dependency injection.
3744
+ * Defines service registration details.
3745
+ *
3746
+ * @example
3747
+ * ```typescript
3748
+ * const config: DependencyInjectionConfig = {
3749
+ * token: UserService,
3750
+ * factory: () => new UserService(db),
3751
+ * dependencies: [DatabaseService],
3752
+ * lifecycle: 'singleton',
3753
+ * cleanup: (instance) => instance.dispose()
3754
+ * };
3755
+ * ```
3756
+ */
2116
3757
  export interface DependencyInjectionConfig {
2117
3758
  token: unknown;
2118
3759
  factory: () => unknown;
@@ -2120,6 +3761,21 @@ export interface DependencyInjectionConfig {
2120
3761
  lifecycle: 'singleton' | 'transient' | 'scoped';
2121
3762
  cleanup?: (instance: unknown) => void;
2122
3763
  }
3764
+ /**
3765
+ * Async lifecycle hook configuration.
3766
+ * Defines async hook behavior and timing.
3767
+ *
3768
+ * @example
3769
+ * ```typescript
3770
+ * const hook: AsyncLifecycleHook = {
3771
+ * name: 'onModuleInit',
3772
+ * method: 'initialize',
3773
+ * timeout: 5000,
3774
+ * shouldReject: false,
3775
+ * expectedError: undefined
3776
+ * };
3777
+ * ```
3778
+ */
2123
3779
  export interface AsyncLifecycleHook {
2124
3780
  name: string;
2125
3781
  method: string;
@@ -2127,6 +3783,25 @@ export interface AsyncLifecycleHook {
2127
3783
  shouldReject?: boolean;
2128
3784
  expectedError?: string | RegExp;
2129
3785
  }
3786
+ /**
3787
+ * Result from lifecycle test harness.
3788
+ * Provides lifecycle tracking methods.
3789
+ *
3790
+ * @template T - Type of instance being tested
3791
+ *
3792
+ * @example
3793
+ * ```typescript
3794
+ * const harness: LifecycleTestHarnessResult<Service> = {
3795
+ * instance: service,
3796
+ * getHooks: () => recordedHooks,
3797
+ * clearHooks: () => { recordedHooks = []; },
3798
+ * getHooksByPhase: (phase) => recordedHooks.filter(h => h.phase === phase),
3799
+ * getLastHook: () => recordedHooks[recordedHooks.length - 1],
3800
+ * expectHookCalled: (method) => expect(recordedHooks).toContainEqual({ method }),
3801
+ * expectHookOrder: (order) => expect(recordedHooks.map(h => h.method)).toEqual(order)
3802
+ * };
3803
+ * ```
3804
+ */
2130
3805
  export interface LifecycleTestHarnessResult<T> {
2131
3806
  instance: T;
2132
3807
  getHooks: () => Array<LifecycleHookRecord>;
@@ -2136,14 +3811,52 @@ export interface LifecycleTestHarnessResult<T> {
2136
3811
  expectHookCalled: (method: string) => void;
2137
3812
  expectHookOrder: (expectedOrder: string[]) => void;
2138
3813
  }
3814
+ /**
3815
+ * Options for graceful shutdown testing.
3816
+ * Configures shutdown behavior and expectations.
3817
+ *
3818
+ * @example
3819
+ * ```typescript
3820
+ * const options: GracefulShutdownOptions = {
3821
+ * shutdownTimeout: 10000,
3822
+ * signals: ['SIGTERM', 'SIGINT'],
3823
+ * expectedCleanupActions: ['close-db', 'stop-server', 'flush-cache']
3824
+ * };
3825
+ * ```
3826
+ */
2139
3827
  export interface GracefulShutdownOptions {
2140
3828
  shutdownTimeout?: number;
2141
3829
  signals?: globalThis.NodeJS.Signals[];
2142
3830
  expectedCleanupActions?: string[];
2143
3831
  }
3832
+ /**
3833
+ * Cleanup function for React hooks.
3834
+ * Provides unmount method.
3835
+ *
3836
+ * @example
3837
+ * ```typescript
3838
+ * const cleanup: HookCleanupFunction = {
3839
+ * unmount: () => { // cleanup hook }
3840
+ * };
3841
+ * ```
3842
+ */
2144
3843
  export interface HookCleanupFunction {
2145
3844
  unmount: () => void;
2146
3845
  }
3846
+ /**
3847
+ * Mock IntersectionObserver entry.
3848
+ * Simulates intersection observer behavior.
3849
+ *
3850
+ * @example
3851
+ * ```typescript
3852
+ * const entry: MockIntersectionObserverEntry = {
3853
+ * target: element,
3854
+ * isIntersecting: true,
3855
+ * intersectionRatio: 0.75,
3856
+ * boundingClientRect: element.getBoundingClientRect()
3857
+ * };
3858
+ * ```
3859
+ */
2147
3860
  export interface MockIntersectionObserverEntry {
2148
3861
  target: Element;
2149
3862
  isIntersecting: boolean;
@@ -2171,24 +3884,85 @@ export type PropertyTestFunction<T> = (value: T) => boolean | Promise<boolean>;
2171
3884
  export type StateTransitionApplyFunction<TState, TAction> = (state: TState, action: TAction) => TState;
2172
3885
  export type CombinationTestFunction<T extends Record<string, unknown[]>> = (combination: TestCombination<T>) => void | Promise<void>;
2173
3886
  export type UnknownFunction = (...args: unknown[]) => unknown;
3887
+ /**
3888
+ * Configuration for spy target.
3889
+ * Defines object, method, and implementation.
3890
+ *
3891
+ * @example
3892
+ * ```typescript
3893
+ * const config: SpyTargetConfig = {
3894
+ * obj: userService,
3895
+ * method: 'findUser',
3896
+ * implementation: () => ({ id: 1, name: 'Test' })
3897
+ * };
3898
+ * ```
3899
+ */
2174
3900
  export interface SpyTargetConfig {
2175
3901
  obj: UnknownRecord;
2176
3902
  method: string;
2177
3903
  implementation?: UnknownFunction;
2178
3904
  }
2179
3905
  export type ModuleMockFactories = Record<string, () => UnknownRecord>;
3906
+ /**
3907
+ * Test case with setup function.
3908
+ * Allows pre-test configuration.
3909
+ *
3910
+ * @template T - Type of instance being tested
3911
+ *
3912
+ * @example
3913
+ * ```typescript
3914
+ * const testCase: TestCaseWithSetup<Calculator> = {
3915
+ * name: 'adds with precision',
3916
+ * args: [0.1, 0.2],
3917
+ * expected: 0.3,
3918
+ * setup: (calc) => calc.setPrecision(10)
3919
+ * };
3920
+ * ```
3921
+ */
2180
3922
  export interface TestCaseWithSetup<T> {
2181
3923
  name: string;
2182
3924
  args: unknown[];
2183
3925
  expected: unknown;
2184
3926
  setup?: (instance: T) => void;
2185
3927
  }
3928
+ /**
3929
+ * Configuration for lifecycle hook testing.
3930
+ * Validates hook execution.
3931
+ *
3932
+ * @template T - Type of instance with lifecycle hooks
3933
+ *
3934
+ * @example
3935
+ * ```typescript
3936
+ * const config: LifecycleHookTestConfig<Component> = {
3937
+ * name: 'componentDidMount',
3938
+ * hook: 'componentDidMount',
3939
+ * expectedCalls: 1,
3940
+ * expectError: false
3941
+ * };
3942
+ * ```
3943
+ */
2186
3944
  export interface LifecycleHookTestConfig<T> {
2187
3945
  name: string;
2188
3946
  hook: keyof T;
2189
3947
  expectedCalls?: number;
2190
3948
  expectError?: boolean;
2191
3949
  }
3950
+ /**
3951
+ * Scenario for error handling tests.
3952
+ * Defines method, arguments, and expected error.
3953
+ *
3954
+ * @template T - Type of instance being tested
3955
+ *
3956
+ * @example
3957
+ * ```typescript
3958
+ * const scenario: ErrorHandlingScenario<UserService> = {
3959
+ * method: 'createUser',
3960
+ * args: [{ email: 'invalid' }],
3961
+ * expectedError: /Invalid email format/,
3962
+ * setup: (service) => service.enableValidation()
3963
+ * };
3964
+ * ```
3965
+ */
2192
3966
  export interface ErrorHandlingScenario<T> {
2193
3967
  method: keyof T;
2194
3968
  args: unknown[];
@@ -2202,6 +3976,21 @@ export type DataHandler<T> = (data: T) => void;
2202
3976
  export type ValueGetter<T> = () => T;
2203
3977
  export type GenericArgsFunction<T> = (...args: unknown[]) => T;
2204
3978
  export type AsyncFunction<T> = () => Promise<T>;
3979
+ /**
3980
+ * Original console methods storage.
3981
+ * Preserves original console functions.
3982
+ *
3983
+ * @example
3984
+ * ```typescript
3985
+ * const original: OriginalConsole = {
3986
+ * log: console.log,
3987
+ * error: console.error,
3988
+ * warn: console.warn,
3989
+ * info: console.info,
3990
+ * debug: console.debug
3991
+ * };
3992
+ * ```
3993
+ */
2205
3994
  export interface OriginalConsole {
2206
3995
  log: typeof globalThis.console.log;
2207
3996
  error: typeof globalThis.console.error;
@@ -2209,6 +3998,21 @@ export interface OriginalConsole {
2209
3998
  info: typeof globalThis.console.info;
2210
3999
  debug: typeof globalThis.console.debug;
2211
4000
  }
4001
+ /**
4002
+ * Information about DOM element.
4003
+ * Contains element metadata and attributes.
4004
+ *
4005
+ * @example
4006
+ * ```typescript
4007
+ * const info: ElementInfo = {
4008
+ * tagName: 'button',
4009
+ * id: 'submit-btn',
4010
+ * className: 'btn btn-primary',
4011
+ * textContent: 'Submit',
4012
+ * attributes: { 'data-testid': 'submit' }
4013
+ * };
4014
+ * ```
4015
+ */
2212
4016
  export interface ElementInfo {
2213
4017
  tagName: string;
2214
4018
  id: string;
@@ -2216,15 +4020,63 @@ export interface ElementInfo {
2216
4020
  textContent: string | null;
2217
4021
  attributes: Record<string, string>;
2218
4022
  }
4023
+ /**
4024
+ * Debounced function with control methods.
4025
+ * Delays execution until after wait period.
4026
+ *
4027
+ * @template T - Type of original function
4028
+ *
4029
+ * @example
4030
+ * ```typescript
4031
+ * const debounced: DebouncedFunction<(value: string) => void> = debounce(
4032
+ * (value) => console.log(value),
4033
+ * 300
4034
+ * );
4035
+ * debounced('test'); // Waits 300ms
4036
+ * debounced.cancel(); // Cancel pending
4037
+ * debounced.flush(); // Execute immediately
4038
+ * ```
4039
+ */
2219
4040
  export interface DebouncedFunction<T extends (...args: unknown[]) => unknown> extends Function {
2220
4041
  (...args: Parameters<T>): void;
2221
4042
  cancel: () => void;
2222
4043
  flush: () => void;
2223
4044
  }
4045
+ /**
4046
+ * Throttled function with control methods.
4047
+ * Limits execution frequency.
4048
+ *
4049
+ * @template T - Type of original function
4050
+ *
4051
+ * @example
4052
+ * ```typescript
4053
+ * const throttled: ThrottledFunction<() => void> = throttle(
4054
+ * () => console.log('scroll'),
4055
+ * 100
4056
+ * );
4057
+ * window.addEventListener('scroll', throttled);
4058
+ * throttled.cancel(); // Cancel pending
4059
+ * ```
4060
+ */
2224
4061
  export interface ThrottledFunction<T extends (...args: unknown[]) => unknown> extends Function {
2225
4062
  (...args: Parameters<T>): void;
2226
4063
  cancel: () => void;
2227
4064
  }
4065
+ /**
4066
+ * Stopwatch for timing operations.
4067
+ * Tracks elapsed time and lap times.
4068
+ *
4069
+ * @example
4070
+ * ```typescript
4071
+ * const stopwatch: Stopwatch = {
4072
+ * start: () => { startTime = Date.now(); },
4073
+ * lap: () => { // record lap return lapTime; },
4074
+ * stop: () => { // stop timing return elapsed; },
4075
+ * getLaps: () => [...laps],
4076
+ * reset: () => { // reset all }
4077
+ * };
4078
+ * ```
4079
+ */
2228
4080
  export interface Stopwatch {
2229
4081
  start(): void;
2230
4082
  lap(): number;
@@ -2232,6 +4084,21 @@ export interface Stopwatch {
2232
4084
  getLaps(): number[];
2233
4085
  reset(): void;
2234
4086
  }
4087
+ /**
4088
+ * Return value from controller test harness.
4089
+ * Provides controller instance and dependencies.
4090
+ *
4091
+ * @template T - Type of controller
4092
+ *
4093
+ * @example
4094
+ * ```typescript
4095
+ * const harness: ControllerTestHarnessReturn<UserController> = {
4096
+ * controller: userController,
4097
+ * moduleRef: { get: (token) => mockService },
4098
+ * logger: mockLogger
4099
+ * };
4100
+ * ```
4101
+ */
2235
4102
  export interface ControllerTestHarnessReturn<T> {
2236
4103
  controller: T;
2237
4104
  moduleRef: {
@@ -2239,6 +4106,24 @@ export interface ControllerTestHarnessReturn<T> {
2239
4106
  };
2240
4107
  logger?: unknown;
2241
4108
  }
4109
+ /**
4110
+ * Return value from service test harness.
4111
+ * Provides service instance and test utilities.
4112
+ *
4113
+ * @template T - Type of service
4114
+ *
4115
+ * @example
4116
+ * ```typescript
4117
+ * const harness: ServiceTestHarnessReturn<UserService> = {
4118
+ * service: userService,
4119
+ * dependencies: new Map([[DatabaseService, mockDb]]),
4120
+ * logger: mockLogger,
4121
+ * resetMocks: () => { // reset all mocks },
4122
+ * expectCalled: (method, times) => expect(service[method]).toHaveBeenCalledTimes(times),
4123
+ * expectCalledWith: (method, ...args) => expect(service[method]).toHaveBeenCalledWith(...args)
4124
+ * };
4125
+ * ```
4126
+ */
2242
4127
  export interface ServiceTestHarnessReturn<T> {
2243
4128
  service: T;
2244
4129
  dependencies: Map<unknown, unknown>;
@@ -2247,42 +4132,176 @@ export interface ServiceTestHarnessReturn<T> {
2247
4132
  expectCalled: (method: keyof T, times?: number) => void;
2248
4133
  expectCalledWith: (method: keyof T, ...args: unknown[]) => void;
2249
4134
  }
4135
+ /**
4136
+ * Class for dynamic NestJS modules.
4137
+ * Provides configuration methods.
4138
+ *
4139
+ * @example
4140
+ * ```typescript
4141
+ * const moduleClass: DynamicModuleClass = {
4142
+ * forRoot: (config) => ({
4143
+ * module: DatabaseModule,
4144
+ * providers: [{ provide: 'CONFIG', useValue: config }],
4145
+ * exports: [DatabaseService]
4146
+ * })
4147
+ * };
4148
+ * ```
4149
+ */
2250
4150
  export interface DynamicModuleClass {
2251
4151
  forRoot: (config: unknown) => Record<string, unknown>;
2252
4152
  }
4153
+ /**
4154
+ * Expectations for dynamic module testing.
4155
+ * Validates module structure.
4156
+ *
4157
+ * @example
4158
+ * ```typescript
4159
+ * const expectations: DynamicModuleExpectations = {
4160
+ * providers: [DatabaseService, ConfigService],
4161
+ * imports: [CommonModule],
4162
+ * exports: [DatabaseService]
4163
+ * };
4164
+ * ```
4165
+ */
2253
4166
  export interface DynamicModuleExpectations {
2254
4167
  providers?: unknown[];
2255
4168
  imports?: unknown[];
2256
4169
  exports?: unknown[];
2257
4170
  }
4171
+ /**
4172
+ * Return value from NestJS test suite setup.
4173
+ * Contains module and providers.
4174
+ *
4175
+ * @example
4176
+ * ```typescript
4177
+ * const setup: NestJSTestSuiteSetupReturn = {
4178
+ * module: testingModule,
4179
+ * providers: new Map([[UserService, mockUserService]])
4180
+ * };
4181
+ * ```
4182
+ */
2258
4183
  export interface NestJSTestSuiteSetupReturn {
2259
4184
  module: unknown;
2260
4185
  providers: Map<unknown, unknown>;
2261
4186
  }
4187
+ /**
4188
+ * Test for provider dependency injection.
4189
+ * Validates DI relationships.
4190
+ *
4191
+ * @example
4192
+ * ```typescript
4193
+ * const test: ProviderInjectionTest = {
4194
+ * token: UserService,
4195
+ * dependencies: [DatabaseService, CacheService],
4196
+ * testFn: (instance, deps) => {
4197
+ * expect(instance).toBeDefined();
4198
+ * expect(deps).toHaveLength(2);
4199
+ * }
4200
+ * };
4201
+ * ```
4202
+ */
2262
4203
  export interface ProviderInjectionTest {
2263
4204
  token: unknown;
2264
4205
  dependencies: unknown[];
2265
4206
  testFn: (instance: unknown, deps: unknown[]) => void;
2266
4207
  }
4208
+ /**
4209
+ * WebSocket ping message.
4210
+ * Used for connection keep-alive.
4211
+ *
4212
+ * @example
4213
+ * ```typescript
4214
+ * const ping: WebSocketPingMessage = {
4215
+ * type: 'ping'
4216
+ * };
4217
+ * ```
4218
+ */
2267
4219
  export interface WebSocketPingMessage {
2268
4220
  type: 'ping';
2269
4221
  }
4222
+ /**
4223
+ * WebSocket pong message.
4224
+ * Response to ping message.
4225
+ *
4226
+ * @example
4227
+ * ```typescript
4228
+ * const pong: WebSocketPongMessage = {
4229
+ * type: 'pong'
4230
+ * };
4231
+ * ```
4232
+ */
2270
4233
  export interface WebSocketPongMessage {
2271
4234
  type: 'pong';
2272
4235
  }
4236
+ /**
4237
+ * WebSocket echo message.
4238
+ * Echoes data back to sender.
4239
+ *
4240
+ * @example
4241
+ * ```typescript
4242
+ * const echo: WebSocketEchoMessage = {
4243
+ * type: 'echo',
4244
+ * data: 'Hello WebSocket'
4245
+ * };
4246
+ * ```
4247
+ */
2273
4248
  export interface WebSocketEchoMessage {
2274
4249
  type: 'echo';
2275
4250
  data: string;
2276
4251
  }
4252
+ /**
4253
+ * Generic typed WebSocket message.
4254
+ * Base structure for custom messages.
4255
+ *
4256
+ * @example
4257
+ * ```typescript
4258
+ * const message: WebSocketTypedMessage = {
4259
+ * type: 'notification',
4260
+ * data: 'User joined the chat'
4261
+ * };
4262
+ * ```
4263
+ */
2277
4264
  export interface WebSocketTypedMessage {
2278
4265
  type: string;
2279
4266
  data: string;
2280
4267
  }
4268
+ /**
4269
+ * Input for Next.js image loader.
4270
+ * Parameters for image optimization.
4271
+ *
4272
+ * @example
4273
+ * ```typescript
4274
+ * const input: ImageLoaderInput = {
4275
+ * src: '/images/hero.jpg',
4276
+ * width: 1920,
4277
+ * quality: 85
4278
+ * };
4279
+ * ```
4280
+ */
2281
4281
  export interface ImageLoaderInput {
2282
4282
  src: string;
2283
4283
  width: number;
2284
4284
  quality?: number;
2285
4285
  }
4286
+ /**
4287
+ * Step in user flow testing.
4288
+ * Defines interactions and assertions.
4289
+ *
4290
+ * @example
4291
+ * ```typescript
4292
+ * const step: UserFlowStep = {
4293
+ * name: 'Login flow',
4294
+ * interactions: [{ type: 'click', target: '#login' }],
4295
+ * assertions: async () => {
4296
+ * expect(screen.getByText('Dashboard')).toBeVisible();
4297
+ * },
4298
+ * navigation: {
4299
+ * expectedUrl: '/dashboard',
4300
+ * waitForNavigation: true
4301
+ * }
4302
+ * };
4303
+ * ```
4304
+ */
2286
4305
  export interface UserFlowStep {
2287
4306
  name: string;
2288
4307
  interactions: InteractionSequence[];
@@ -2292,6 +4311,23 @@ export interface UserFlowStep {
2292
4311
  waitForNavigation?: boolean;
2293
4312
  };
2294
4313
  }
4314
+ /**
4315
+ * Parameters for creating mock Next.js request.
4316
+ * Configures request properties.
4317
+ *
4318
+ * @example
4319
+ * ```typescript
4320
+ * const params: MockNextRequestCreatorParams = {
4321
+ * url: 'https://example.com/api/users',
4322
+ * options: {
4323
+ * method: 'POST',
4324
+ * headers: { 'Content-Type': 'application/json' },
4325
+ * body: { name: 'John' },
4326
+ * searchParams: { page: '1' }
4327
+ * }
4328
+ * };
4329
+ * ```
4330
+ */
2295
4331
  export interface MockNextRequestCreatorParams {
2296
4332
  url: string;
2297
4333
  options?: {
@@ -2301,11 +4337,44 @@ export interface MockNextRequestCreatorParams {
2301
4337
  searchParams?: Record<string, string>;
2302
4338
  };
2303
4339
  }
4340
+ /**
4341
+ * Provider injection configuration.
4342
+ * Maps providers to dependencies.
4343
+ *
4344
+ * @example
4345
+ * ```typescript
4346
+ * const injection: ProviderInjection = {
4347
+ * token: UserService,
4348
+ * dependencies: [DatabaseService],
4349
+ * testFn: (instance, deps) => {
4350
+ * expect(instance).toBeInstanceOf(UserService);
4351
+ * }
4352
+ * };
4353
+ * ```
4354
+ */
2304
4355
  export interface ProviderInjection {
2305
4356
  token: unknown;
2306
4357
  dependencies: unknown[];
2307
4358
  testFn: (instance: unknown, deps: unknown[]) => void;
2308
4359
  }
4360
+ /**
4361
+ * Mock Redis client interface.
4362
+ * Provides mocked Redis operations.
4363
+ *
4364
+ * @example
4365
+ * ```typescript
4366
+ * const redis: CreateMockRedisClientMock = {
4367
+ * set: vi.fn().mockResolvedValue('OK'),
4368
+ * get: vi.fn().mockResolvedValue('value'),
4369
+ * del: vi.fn().mockResolvedValue(1),
4370
+ * keys: vi.fn().mockResolvedValue(['key1', 'key2']),
4371
+ * quit: vi.fn(),
4372
+ * on: vi.fn(),
4373
+ * multi: vi.fn(),
4374
+ * ping: vi.fn().mockResolvedValue('PONG')
4375
+ * };
4376
+ * ```
4377
+ */
2309
4378
  export interface CreateMockRedisClientMock {
2310
4379
  set: Vitest.Mock;
2311
4380
  get: Vitest.Mock;
@@ -2317,8 +4386,17 @@ export interface CreateMockRedisClientMock {
2317
4386
  ping: Vitest.Mock;
2318
4387
  }
2319
4388
  /**
2320
- * Call tracker interface
2321
- * @interface CallTracker
4389
+ * Call tracker for monitoring function calls.
4390
+ * Records call history with arguments and timestamps.
4391
+ *
4392
+ * @example
4393
+ * ```typescript
4394
+ * const tracker: CallTracker = {
4395
+ * trackCall: (name, args) => calls.push({ name, args, timestamp: Date.now() }),
4396
+ * getCalls: (name) => name ? calls.filter(c => c.name === name) : calls,
4397
+ * reset: () => { calls = []; }
4398
+ * };
4399
+ * ```
2322
4400
  */
2323
4401
  export interface CallTracker {
2324
4402
  trackCall: (name: string, args: unknown[]) => void;
@@ -2330,9 +4408,20 @@ export interface CallTracker {
2330
4408
  reset: () => void;
2331
4409
  }
2332
4410
  /**
2333
- * Tracked spy with additional properties
2334
- * @interface TrackedSpy
2335
- * @extends SpyInstance
4411
+ * Enhanced spy with tracking capabilities.
4412
+ * Extends Vitest spy with call history methods.
4413
+ *
4414
+ * @example
4415
+ * ```typescript
4416
+ * const spy: TrackedSpy = Object.assign(vi.fn(), {
4417
+ * getCallCount: () => spy.mock.calls.length,
4418
+ * getCallHistory: () => spy.mock.calls.map((args, i) => ({
4419
+ * args,
4420
+ * result: spy.mock.results[i]?.value,
4421
+ * error: spy.mock.results[i]?.type === 'throw' ? spy.mock.results[i].value : undefined
4422
+ * }))
4423
+ * });
4424
+ * ```
2336
4425
  */
2337
4426
  export interface TrackedSpy extends SpyInstance {
2338
4427
  getCallCount: () => number;
@@ -2350,9 +4439,21 @@ export type SpyMap<T> = {
2350
4439
  [K in keyof T]: SpyInstance;
2351
4440
  };
2352
4441
  /**
2353
- * Tracked data interface
2354
- * @interface TrackedData
2355
- * @typeParam T - Type of tracked data
4442
+ * Data wrapper with access tracking.
4443
+ * Records property access history.
4444
+ *
4445
+ * @template T - Type of data being tracked
4446
+ *
4447
+ * @example
4448
+ * ```typescript
4449
+ * const tracked: TrackedData<User> = {
4450
+ * data: { id: 1, name: 'John' },
4451
+ * accesses: [
4452
+ * { property: 'name', timestamp: 1699123456 },
4453
+ * { property: 'id', timestamp: 1699123457 }
4454
+ * ]
4455
+ * };
4456
+ * ```
2356
4457
  */
2357
4458
  export interface TrackedData<T> {
2358
4459
  data: T;
@@ -2362,8 +4463,17 @@ export interface TrackedData<T> {
2362
4463
  }>;
2363
4464
  }
2364
4465
  /**
2365
- * Access information
2366
- * @interface AccessInfo
4466
+ * Information about property access.
4467
+ * Tracks access frequency and timing.
4468
+ *
4469
+ * @example
4470
+ * ```typescript
4471
+ * const access: AccessInfo = {
4472
+ * property: 'userName',
4473
+ * timestamp: Date.now(),
4474
+ * count: 5
4475
+ * };
4476
+ * ```
2367
4477
  */
2368
4478
  export interface AccessInfo {
2369
4479
  property: string | symbol;
@@ -2371,8 +4481,18 @@ export interface AccessInfo {
2371
4481
  count: number;
2372
4482
  }
2373
4483
  /**
2374
- * Worker-like interface for various worker types
2375
- * @interface WorkerLike
4484
+ * Unified interface for different worker implementations.
4485
+ * Compatible with Web Workers, Worker Threads, and custom workers.
4486
+ *
4487
+ * @example
4488
+ * ```typescript
4489
+ * const worker: WorkerLike = {
4490
+ * postMessage: (msg) => { // send message },
4491
+ * onmessage: (event) => { // handle message },
4492
+ * onerror: (error) => { // handle error },
4493
+ * terminate: () => { // cleanup }
4494
+ * };
4495
+ * ```
2376
4496
  */
2377
4497
  export interface WorkerLike {
2378
4498
  onError?: (error: Error) => void;
@@ -2393,8 +4513,27 @@ export interface WorkerLike {
2393
4513
  terminate?: () => void;
2394
4514
  }
2395
4515
  /**
2396
- * Worker pool interface
2397
- * @interface WorkerPool
4516
+ * Pool of workers for parallel task execution.
4517
+ * Manages worker lifecycle and task distribution.
4518
+ *
4519
+ * @example
4520
+ * ```typescript
4521
+ * const pool: WorkerPool = {
4522
+ * addTask: (task) => taskQueue.push(task),
4523
+ * start: async () => { // initialize workers },
4524
+ * stop: () => { // terminate workers },
4525
+ * waitForCompletion: async () => { // wait for all tasks },
4526
+ * getStats: () => ({
4527
+ * totalWorkers: 4,
4528
+ * busyWorkers: 2,
4529
+ * idleWorkers: 2,
4530
+ * tasksCompleted: 100,
4531
+ * tasksFailed: 2,
4532
+ * tasksRemaining: 10,
4533
+ * workerStats: [// per-worker stats]
4534
+ * })
4535
+ * };
4536
+ * ```
2398
4537
  */
2399
4538
  export interface WorkerPool {
2400
4539
  addTask: (task: () => Promise<void>) => void;
@@ -2416,8 +4555,22 @@ export interface WorkerPool {
2416
4555
  };
2417
4556
  }
2418
4557
  /**
2419
- * Worker metrics interface
2420
- * @interface WorkerMetrics
4558
+ * Performance metrics for individual workers.
4559
+ * Tracks execution statistics and resource usage.
4560
+ *
4561
+ * @example
4562
+ * ```typescript
4563
+ * const metrics: WorkerMetrics = {
4564
+ * workerId: 1,
4565
+ * taskCount: 50,
4566
+ * executionTime: 5000,
4567
+ * errors: [],
4568
+ * throughput: 10, // tasks per second
4569
+ * avgTaskTime: 100,
4570
+ * memoryUsage: 50 * 1024 * 1024,
4571
+ * cpuUsage: 25
4572
+ * };
4573
+ * ```
2421
4574
  */
2422
4575
  export interface WorkerMetrics {
2423
4576
  workerId: number;
@@ -2430,8 +4583,31 @@ export interface WorkerMetrics {
2430
4583
  cpuUsage?: number;
2431
4584
  }
2432
4585
  /**
2433
- * Worker test harness interface
2434
- * @interface WorkerTestHarness
4586
+ * Test harness for worker pool testing.
4587
+ * Provides methods to run and validate worker tests.
4588
+ *
4589
+ * @example
4590
+ * ```typescript
4591
+ * const harness: WorkerTestHarness = {
4592
+ * run: async () => ({
4593
+ * metrics: [// worker metrics],
4594
+ * totalExecutionTime: 10000,
4595
+ * totalTasks: 100,
4596
+ * totalErrors: 2
4597
+ * }),
4598
+ * assertResults: (results) => {
4599
+ * expect(results.totalErrors).toBeLessThan(5);
4600
+ * },
4601
+ * getMetrics: () => ({
4602
+ * workerCount: 4,
4603
+ * totalTasks: 100,
4604
+ * avgExecutionTime: 100,
4605
+ * avgThroughput: 10,
4606
+ * errorCount: 2,
4607
+ * workerMetrics: [// metrics]
4608
+ * })
4609
+ * };
4610
+ * ```
2435
4611
  */
2436
4612
  export interface WorkerTestHarness {
2437
4613
  run: () => Promise<{
@@ -2456,8 +4632,21 @@ export interface WorkerTestHarness {
2456
4632
  };
2457
4633
  }
2458
4634
  /**
2459
- * Worker spy interface
2460
- * @interface WorkerSpy
4635
+ * Spy for worker communication testing.
4636
+ * Tracks messages and simulates worker behavior.
4637
+ *
4638
+ * @example
4639
+ * ```typescript
4640
+ * const spy: WorkerSpy = {
4641
+ * getMessagesSent: () => sentMessages,
4642
+ * getMessagesReceived: () => receivedMessages,
4643
+ * getErrors: () => errors,
4644
+ * isTerminated: () => terminated,
4645
+ * simulateMessage: (msg) => worker.onmessage({ data: msg }),
4646
+ * simulateError: (err) => worker.onerror(err),
4647
+ * reset: () => { // clear all data }
4648
+ * };
4649
+ * ```
2461
4650
  */
2462
4651
  export interface WorkerSpy {
2463
4652
  getMessagesSent: () => unknown[];
@@ -2469,149 +4658,227 @@ export interface WorkerSpy {
2469
4658
  reset: () => void;
2470
4659
  }
2471
4660
  /**
2472
- * Performance profiling options
2473
- * @interface ProfileOptions
4661
+ * Options for performance profiling.
4662
+ * Configures what metrics to collect.
4663
+ *
4664
+ * @example
4665
+ * ```typescript
4666
+ * const options: ProfileOptions = {
4667
+ * sampleInterval: 10,
4668
+ * includeMemory: true,
4669
+ * includeCPU: true
4670
+ * };
4671
+ * ```
2474
4672
  */
2475
4673
  export interface ProfileOptions {
2476
- /** Sample interval in milliseconds */
2477
4674
  sampleInterval?: number;
2478
- /** Include memory profiling */
2479
4675
  includeMemory?: boolean;
2480
- /** Include CPU profiling */
2481
4676
  includeCPU?: boolean;
2482
4677
  }
2483
4678
  /**
2484
- * Performance profile result
2485
- * @interface ProfileResult
2486
- * @typeParam T - Type of profiled operation result
4679
+ * Result from performance profiling.
4680
+ * Contains operation result and performance data.
4681
+ *
4682
+ * @template T - Type of profiled operation result
4683
+ *
4684
+ * @example
4685
+ * ```typescript
4686
+ * const profile: ProfileResult<string> = {
4687
+ * result: 'operation completed',
4688
+ * cpuProfile: {
4689
+ * samples: [10, 15, 20, 18],
4690
+ * timestamps: [0, 10, 20, 30],
4691
+ * duration: 30
4692
+ * },
4693
+ * memoryProfile: {
4694
+ * samples: [1000, 1500, 2000],
4695
+ * timestamps: [0, 15, 30]
4696
+ * }
4697
+ * };
4698
+ * ```
2487
4699
  */
2488
4700
  export interface ProfileResult<T> {
2489
- /** Operation result */
2490
4701
  result: T;
2491
- /** CPU profile data */
2492
4702
  cpuProfile?: {
2493
- /** Profile samples */
2494
4703
  samples: number[];
2495
- /** Sample timestamps */
2496
4704
  timestamps: number[];
2497
4705
  duration: number;
2498
4706
  };
2499
- /** Memory profile data */
2500
4707
  memoryProfile?: {
2501
- /** Memory usage samples */
2502
4708
  samples: number[];
2503
- /** Memory timestamps */
2504
4709
  timestamps: number[];
2505
4710
  };
2506
4711
  }
2507
4712
  /**
2508
- * Stress testing options
2509
- * @interface StressTestOptions
4713
+ * Options for stress testing.
4714
+ * Configures load parameters and error thresholds.
4715
+ *
4716
+ * @example
4717
+ * ```typescript
4718
+ * const options: StressTestOptions = {
4719
+ * duration: 60000, // 1 minute
4720
+ * concurrency: 100,
4721
+ * rampUp: 5000,
4722
+ * maxErrors: 50,
4723
+ * errorThreshold: 0.05 // 5% error rate
4724
+ * };
4725
+ * ```
2510
4726
  */
2511
4727
  export interface StressTestOptions {
2512
- /** Test duration in milliseconds */
2513
4728
  duration?: number;
2514
- /** Number of concurrent operations */
2515
4729
  concurrency?: number;
2516
- /** Ramp-up time */
2517
4730
  rampUp?: number;
2518
4731
  maxErrors?: number;
2519
4732
  errorThreshold?: number;
2520
4733
  }
2521
4734
  /**
2522
- * Stress test result
2523
- * @interface StressTestResult
4735
+ * Results from stress testing.
4736
+ * Contains operation statistics and error information.
4737
+ *
4738
+ * @example
4739
+ * ```typescript
4740
+ * const result: StressTestResult = {
4741
+ * totalOperations: 10000,
4742
+ * successfulOperations: 9500,
4743
+ * failedOperations: 500,
4744
+ * averageResponseTime: 150,
4745
+ * operationsPerSecond: 166.67,
4746
+ * errorRate: 0.05,
4747
+ * errors: [// error objects]
4748
+ * };
4749
+ * ```
2524
4750
  */
2525
4751
  export interface StressTestResult {
2526
- /** Total operations performed */
2527
4752
  totalOperations: number;
2528
- /** Successful operations */
2529
4753
  successfulOperations: number;
2530
- /** Failed operations */
2531
4754
  failedOperations: number;
2532
- /** Average response time */
2533
4755
  averageResponseTime: number;
2534
4756
  operationsPerSecond: number;
2535
4757
  errorRate: number;
2536
4758
  errors: Error[];
2537
4759
  }
2538
4760
  /**
2539
- * Throughput test result
2540
- * @interface ThroughputResult
4761
+ * Results from throughput testing.
4762
+ * Measures operation rate and latency.
4763
+ *
4764
+ * @example
4765
+ * ```typescript
4766
+ * const result: ThroughputResult = {
4767
+ * operationsCompleted: 1000,
4768
+ * duration: 10000,
4769
+ * throughput: 100, // ops per second
4770
+ * averageLatency: 10,
4771
+ * minLatency: 5,
4772
+ * maxLatency: 50
4773
+ * };
4774
+ * ```
2541
4775
  */
2542
4776
  export interface ThroughputResult {
2543
- /** Operations completed */
2544
4777
  operationsCompleted: number;
2545
- /** Test duration */
2546
4778
  duration: number;
2547
- /** Throughput rate */
2548
4779
  throughput: number;
2549
4780
  averageLatency: number;
2550
4781
  minLatency: number;
2551
4782
  maxLatency: number;
2552
4783
  }
2553
4784
  /**
2554
- * Performance monitoring options
2555
- * @interface MonitorOptions
4785
+ * Options for performance monitoring.
4786
+ * Configures metrics collection.
4787
+ *
4788
+ * @example
4789
+ * ```typescript
4790
+ * const options: MonitorOptions = {
4791
+ * interval: 100, // sample every 100ms
4792
+ * metrics: ['cpu', 'memory', 'time']
4793
+ * };
4794
+ * ```
2556
4795
  */
2557
4796
  export interface MonitorOptions {
2558
- /** Monitoring interval */
2559
4797
  interval?: number;
2560
- /** Metrics to collect */
2561
4798
  metrics?: Array<'cpu' | 'memory' | 'time'>;
2562
4799
  }
2563
4800
  /**
2564
- * Performance monitor interface
2565
- * @interface PerformanceMonitor
4801
+ * Monitor for collecting performance metrics.
4802
+ * Provides real-time performance tracking.
4803
+ *
4804
+ * @example
4805
+ * ```typescript
4806
+ * const monitor: PerformanceMonitor = {
4807
+ * start: () => { // begin monitoring },
4808
+ * stop: () => { // stop monitoring },
4809
+ * getMetrics: () => ({
4810
+ * cpu: [25, 30, 28, 35],
4811
+ * memory: [100, 110, 115, 120],
4812
+ * timestamps: [0, 100, 200, 300]
4813
+ * })
4814
+ * };
4815
+ * ```
2566
4816
  */
2567
4817
  export interface PerformanceMonitor {
2568
- /** Start monitoring */
2569
4818
  start: () => void;
2570
- /** Stop monitoring */
2571
4819
  stop: () => void;
2572
- /** Get collected metrics */
2573
4820
  getMetrics: () => {
2574
- /** CPU metrics */
2575
4821
  cpu?: number[];
2576
- /** Memory metrics */
2577
4822
  memory?: number[];
2578
- /** Time metrics */
2579
4823
  timestamps: number[];
2580
4824
  };
2581
4825
  }
2582
4826
  /**
2583
- * Memory leak testing options
2584
- * @interface LeakOptions
4827
+ * Options for memory leak testing.
4828
+ * Configures leak detection parameters.
4829
+ *
4830
+ * @example
4831
+ * ```typescript
4832
+ * const options: LeakOptions = {
4833
+ * iterations: 100,
4834
+ * threshold: 10 * 1024 * 1024, // 10MB
4835
+ * gcBetweenRuns: true
4836
+ * };
4837
+ * ```
2585
4838
  */
2586
4839
  export interface LeakOptions {
2587
- /** Number of test iterations */
2588
4840
  iterations?: number;
2589
- /** Memory threshold */
2590
4841
  threshold?: number;
2591
- /** Run GC between runs */
2592
4842
  gcBetweenRuns?: boolean;
2593
4843
  }
2594
4844
  /**
2595
- * Memory leak test result
2596
- * @interface LeakResult
4845
+ * Result from memory leak testing.
4846
+ * Indicates leak presence and growth rate.
4847
+ *
4848
+ * @example
4849
+ * ```typescript
4850
+ * const result: LeakResult = {
4851
+ * hasLeak: true,
4852
+ * memoryGrowth: 5 * 1024 * 1024, // 5MB growth
4853
+ * measurements: [
4854
+ * { iteration: 0, memory: 50000000 },
4855
+ * { iteration: 50, memory: 52500000 },
4856
+ * { iteration: 100, memory: 55000000 }
4857
+ * ]
4858
+ * };
4859
+ * ```
2597
4860
  */
2598
4861
  export interface LeakResult {
2599
- /** Whether leak was detected */
2600
4862
  hasLeak: boolean;
2601
- /** Memory growth amount */
2602
4863
  memoryGrowth: number;
2603
- /** Memory measurements */
2604
4864
  measurements: Array<{
2605
- /** Iteration number */
2606
4865
  iteration: number;
2607
- /** Memory usage */
2608
4866
  memory: number;
2609
4867
  }>;
2610
4868
  }
2611
4869
  /**
2612
- * Hook testing scenario
2613
- * @interface HookScenario
2614
- * @typeParam T - Type of hook result
4870
+ * Scenario for testing React hooks.
4871
+ * Defines actions and expected state.
4872
+ *
4873
+ * @example
4874
+ * ```typescript
4875
+ * const scenario: HookScenario = {
4876
+ * name: 'increment counter',
4877
+ * action: () => result.current.increment(),
4878
+ * expectedState: { count: 1, loading: false },
4879
+ * expectedError: null
4880
+ * };
4881
+ * ```
2615
4882
  */
2616
4883
  export interface HookScenario {
2617
4884
  name: string;
@@ -2798,7 +5065,7 @@ export interface DragOptions {
2798
5065
  steps?: number;
2799
5066
  dropEffect?: 'move' | 'copy' | 'link' | 'none';
2800
5067
  }
2801
- export type TouchGestureAdvancedAdvanced = {
5068
+ export type TouchGestureAdvanced = {
2802
5069
  type: 'tap';
2803
5070
  x: number;
2804
5071
  y: number;
@@ -2847,36 +5114,24 @@ export interface Interaction {
2847
5114
  * @interface SwipeGestureParams
2848
5115
  */
2849
5116
  export interface SwipeGestureParams {
2850
- /** Start coordinates */
2851
- start: {
2852
- x: number;
2853
- y: number;
2854
- };
2855
- /** End coordinates */
2856
- end: {
2857
- x: number;
2858
- y: number;
2859
- };
2860
- /** Gesture duration */
2861
- duration?: number;
2862
- /** Number of touch points */
2863
- touches?: number;
5117
+ element: Element;
5118
+ startX: number;
5119
+ startY: number;
5120
+ endX: number;
5121
+ endY: number;
5122
+ duration: number;
2864
5123
  }
2865
5124
  /**
2866
5125
  * Pinch gesture parameters
2867
5126
  * @interface PinchGestureParams
2868
5127
  */
2869
5128
  export interface PinchGestureParams {
2870
- /** Center coordinates */
2871
5129
  center: {
2872
5130
  x: number;
2873
5131
  y: number;
2874
5132
  };
2875
- /** Scale factor */
2876
5133
  scale: number;
2877
- /** Gesture duration */
2878
5134
  duration?: number;
2879
- /** Rotation angle */
2880
5135
  rotation?: number;
2881
5136
  }
2882
5137
  /**
@@ -2928,12 +5183,9 @@ export interface IntervalHandle {
2928
5183
  * @interface ScheduleHandle
2929
5184
  */
2930
5185
  export interface ScheduleHandle {
2931
- /** Timeout ID */
2932
- id: number;
2933
- /** Cancel schedule */
2934
- cancel: () => void;
2935
- /** Check if pending */
2936
- isPending: () => boolean;
5186
+ stop: () => void;
5187
+ nextRun: () => Date | null;
5188
+ isRunning: () => boolean;
2937
5189
  }
2938
5190
  /**
2939
5191
  * Timer interface
@@ -2960,14 +5212,11 @@ export interface Countdown {
2960
5212
  * @interface HistoryEntry
2961
5213
  */
2962
5214
  export interface MockHistoryEntry {
2963
- /** Entry URL */
2964
- url: string;
2965
- /** Entry state */
5215
+ pathname: string;
5216
+ search?: string;
5217
+ hash?: string;
2966
5218
  state?: unknown;
2967
- /** Entry title */
2968
- title?: string;
2969
- /** Entry timestamp */
2970
- timestamp: number;
5219
+ key?: string;
2971
5220
  }
2972
5221
  /**
2973
5222
  * Mock history object
@@ -2993,15 +5242,10 @@ export interface MockHistory {
2993
5242
  * @interface MockLocation
2994
5243
  */
2995
5244
  export interface MockLocation {
2996
- /** Current pathname */
2997
5245
  pathname: string;
2998
- /** Current search */
2999
5246
  search: string;
3000
- /** Current hash */
3001
5247
  hash: string;
3002
- /** Current state */
3003
5248
  state: unknown;
3004
- /** Location key */
3005
5249
  key: string;
3006
5250
  href: string;
3007
5251
  origin: string;
@@ -3044,9 +5288,7 @@ export interface GuardScenario {
3044
5288
  * @interface NavOptions
3045
5289
  */
3046
5290
  export interface NavOptions {
3047
- /** Replace current entry */
3048
5291
  replace?: boolean;
3049
- /** Navigation state */
3050
5292
  state?: unknown;
3051
5293
  shallow?: boolean;
3052
5294
  }
@@ -3118,13 +5360,9 @@ export interface APIRequest {
3118
5360
  * @interface LifecycleScenario
3119
5361
  */
3120
5362
  export interface LifecycleScenario {
3121
- /** Scenario name */
3122
5363
  name: string;
3123
- /** Action to perform */
3124
5364
  action: () => void | Promise<void>;
3125
- /** Expected state after action */
3126
5365
  expectedState?: Record<string, unknown>;
3127
- /** Expected events */
3128
5366
  expectedEvents?: string[];
3129
5367
  }
3130
5368
  /**
@@ -3132,21 +5370,17 @@ export interface LifecycleScenario {
3132
5370
  * @interface LifecycleTracker
3133
5371
  */
3134
5372
  export interface LifecycleTracker {
3135
- /** Recorded events */
3136
5373
  events: Array<{
3137
5374
  type: string;
3138
5375
  timestamp: number;
3139
5376
  data?: unknown;
3140
5377
  }>;
3141
- /** Clear all events */
3142
5378
  clear: () => void;
3143
- /** Get all events */
3144
5379
  getEvents: () => Array<{
3145
5380
  type: string;
3146
5381
  timestamp: number;
3147
5382
  data?: unknown;
3148
5383
  }>;
3149
- /** Get events by type */
3150
5384
  getEventsByType: (type: string) => Array<{
3151
5385
  type: string;
3152
5386
  timestamp: number;
@@ -3158,9 +5392,7 @@ export interface LifecycleTracker {
3158
5392
  * @interface LifecycleEvent
3159
5393
  */
3160
5394
  export interface LifecycleEvent {
3161
- /** Event type */
3162
5395
  type: string;
3163
- /** Event data */
3164
5396
  data?: unknown;
3165
5397
  }
3166
5398
  /**
@@ -3168,11 +5400,8 @@ export interface LifecycleEvent {
3168
5400
  * @interface CleanupResult
3169
5401
  */
3170
5402
  export interface CleanupResult {
3171
- /** Whether cleanup was successful */
3172
5403
  cleanedUp: boolean;
3173
- /** Cleaned up resources */
3174
5404
  resources: string[];
3175
- /** Cleanup errors */
3176
5405
  errors: Error[];
3177
5406
  }
3178
5407
  /**
@@ -3180,11 +5409,8 @@ export interface CleanupResult {
3180
5409
  * @interface LifecycleMetrics
3181
5410
  */
3182
5411
  export interface LifecycleMetrics {
3183
- /** Mount time */
3184
5412
  mountTime: number;
3185
- /** Update time */
3186
5413
  updateTime: number;
3187
- /** Unmount time */
3188
5414
  unmountTime: number;
3189
5415
  totalLifecycleTime: number;
3190
5416
  renderCount: number;
@@ -3194,15 +5420,10 @@ export interface LifecycleMetrics {
3194
5420
  * @interface FileSnapshot
3195
5421
  */
3196
5422
  export interface FileSnapshot {
3197
- /** File path */
3198
5423
  path: string;
3199
- /** File size */
3200
5424
  size: number;
3201
- /** Modification time */
3202
5425
  mtime: Date;
3203
- /** File content */
3204
5426
  content: string;
3205
- /** Content hash */
3206
5427
  hash: string;
3207
5428
  }
3208
5429
  /**
@@ -3220,7 +5441,6 @@ interface EnvConfig {
3220
5441
  * @interface TestEnvironment
3221
5442
  */
3222
5443
  export interface TestEnvironment {
3223
- /** Get environment variable */
3224
5444
  get: (key: string) => string | undefined;
3225
5445
  set: (key: string, value: string) => void;
3226
5446
  reset: () => void;
@@ -3231,7 +5451,6 @@ export interface TestEnvironment {
3231
5451
  * @interface EnvMock
3232
5452
  */
3233
5453
  export interface EnvMock {
3234
- /** Restore original environment */
3235
5454
  restore: () => void;
3236
5455
  update: (vars: Record<string, string>) => void;
3237
5456
  clear: () => void;
@@ -3241,7 +5460,6 @@ export interface EnvMock {
3241
5460
  * @interface EnvSnapshot
3242
5461
  */
3243
5462
  export interface EnvSnapshot {
3244
- /** Environment variables */
3245
5463
  variables: Record<string, string | undefined>;
3246
5464
  timestamp: number;
3247
5465
  }