@plyaz/types 1.5.1 → 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.
- package/dist/features/feature-flag/types.d.ts +28 -4
- package/dist/testing/common/factories/types.d.ts +92 -56
- package/dist/testing/common/mocks/types.d.ts +608 -377
- package/dist/testing/common/patterns/types.d.ts +28 -10
- package/dist/testing/common/utils/types.d.ts +2995 -618
- package/dist/testing/features/cache/types.d.ts +127 -54
- package/dist/testing/features/feature-flags/types.d.ts +249 -128
- package/package.json +1 -1
|
@@ -56,32 +56,32 @@ import type * as NextLink from 'next/link';
|
|
|
56
56
|
*/
|
|
57
57
|
export interface MockFS {
|
|
58
58
|
/** Async read file */
|
|
59
|
-
readFile: Vitest.
|
|
59
|
+
readFile: Vitest.Mock;
|
|
60
60
|
/** Async write file */
|
|
61
|
-
writeFile: Vitest.
|
|
61
|
+
writeFile: Vitest.Mock;
|
|
62
62
|
/** Sync read file */
|
|
63
|
-
readFileSync: Vitest.
|
|
63
|
+
readFileSync: Vitest.Mock;
|
|
64
64
|
/** Sync write file */
|
|
65
|
-
writeFileSync: Vitest.
|
|
65
|
+
writeFileSync: Vitest.Mock;
|
|
66
66
|
/** Check if path exists */
|
|
67
|
-
existsSync: Vitest.
|
|
67
|
+
existsSync: Vitest.Mock;
|
|
68
68
|
/** Create directory */
|
|
69
|
-
mkdirSync: Vitest.
|
|
69
|
+
mkdirSync: Vitest.Mock;
|
|
70
70
|
/** Read directory contents */
|
|
71
|
-
readdirSync: Vitest.
|
|
71
|
+
readdirSync: Vitest.Mock;
|
|
72
72
|
/** Get file stats */
|
|
73
|
-
statSync: Vitest.
|
|
73
|
+
statSync: Vitest.Mock;
|
|
74
74
|
/** Delete file */
|
|
75
|
-
unlinkSync: Vitest.
|
|
75
|
+
unlinkSync: Vitest.Mock;
|
|
76
76
|
/** Remove file or directory */
|
|
77
|
-
rmSync: Vitest.
|
|
77
|
+
rmSync: Vitest.Mock;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
80
|
* Mock process interface matching Node.js process global
|
|
81
81
|
*
|
|
82
82
|
* @example
|
|
83
83
|
* ```typescript
|
|
84
|
-
* const mockProcess: Vitest.
|
|
84
|
+
* const mockProcess: Vitest.MockProcess = createMockProcess();
|
|
85
85
|
*
|
|
86
86
|
* // Mock environment
|
|
87
87
|
* mockProcess.env.NODE_ENV = 'test';
|
|
@@ -96,25 +96,25 @@ export interface MockProcess {
|
|
|
96
96
|
/** Environment variables */
|
|
97
97
|
env: Record<string, string | undefined>;
|
|
98
98
|
/** Exit the process */
|
|
99
|
-
exit: Vitest.
|
|
99
|
+
exit: Vitest.Mock;
|
|
100
100
|
/** Get current working directory */
|
|
101
|
-
cwd: Vitest.
|
|
101
|
+
cwd: Vitest.Mock;
|
|
102
102
|
/** Change current directory */
|
|
103
|
-
chdir: Vitest.
|
|
103
|
+
chdir: Vitest.Mock;
|
|
104
104
|
/** Standard output stream */
|
|
105
105
|
stdout: {
|
|
106
106
|
/** Write to stdout */
|
|
107
|
-
write: Vitest.
|
|
107
|
+
write: Vitest.Mock;
|
|
108
108
|
};
|
|
109
109
|
/** Standard error stream */
|
|
110
110
|
stderr: {
|
|
111
111
|
/** Write to stderr */
|
|
112
|
-
write: Vitest.
|
|
112
|
+
write: Vitest.Mock;
|
|
113
113
|
};
|
|
114
114
|
/** Add event listener */
|
|
115
|
-
on: Vitest.
|
|
115
|
+
on: Vitest.Mock;
|
|
116
116
|
/** Remove event listener */
|
|
117
|
-
removeListener: Vitest.
|
|
117
|
+
removeListener: Vitest.Mock;
|
|
118
118
|
}
|
|
119
119
|
/**
|
|
120
120
|
* Mock crypto interface matching Node.js crypto module
|
|
@@ -135,13 +135,13 @@ export interface MockProcess {
|
|
|
135
135
|
*/
|
|
136
136
|
export interface MockCrypto {
|
|
137
137
|
/** Generate random bytes */
|
|
138
|
-
randomBytes: Vitest.
|
|
138
|
+
randomBytes: Vitest.Mock;
|
|
139
139
|
/** Generate random UUID */
|
|
140
|
-
randomUUID: Vitest.
|
|
140
|
+
randomUUID: Vitest.Mock;
|
|
141
141
|
/** Create hash object */
|
|
142
|
-
createHash: Vitest.
|
|
142
|
+
createHash: Vitest.Mock;
|
|
143
143
|
/** Create HMAC object */
|
|
144
|
-
createHmac: Vitest.
|
|
144
|
+
createHmac: Vitest.Mock;
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* Mock path interface matching Node.js path module
|
|
@@ -158,21 +158,21 @@ export interface MockCrypto {
|
|
|
158
158
|
*/
|
|
159
159
|
export interface MockPath {
|
|
160
160
|
/** Join path segments */
|
|
161
|
-
join: Vitest.
|
|
161
|
+
join: Vitest.Mock;
|
|
162
162
|
/** Resolve absolute path */
|
|
163
|
-
resolve: Vitest.
|
|
163
|
+
resolve: Vitest.Mock;
|
|
164
164
|
/** Get directory name */
|
|
165
|
-
dirname: Vitest.
|
|
165
|
+
dirname: Vitest.Mock;
|
|
166
166
|
/** Get base name */
|
|
167
|
-
basename: Vitest.
|
|
167
|
+
basename: Vitest.Mock;
|
|
168
168
|
/** Get file extension */
|
|
169
|
-
extname: Vitest.
|
|
169
|
+
extname: Vitest.Mock;
|
|
170
170
|
/** Get relative path */
|
|
171
|
-
relative: Vitest.
|
|
171
|
+
relative: Vitest.Mock;
|
|
172
172
|
/** Check if path is absolute */
|
|
173
|
-
isAbsolute: Vitest.
|
|
173
|
+
isAbsolute: Vitest.Mock;
|
|
174
174
|
/** Normalize path */
|
|
175
|
-
normalize: Vitest.
|
|
175
|
+
normalize: Vitest.Mock;
|
|
176
176
|
/** Path separator for platform */
|
|
177
177
|
sep: string;
|
|
178
178
|
}
|
|
@@ -192,13 +192,13 @@ export interface MockPath {
|
|
|
192
192
|
*/
|
|
193
193
|
export interface MockChildProcess {
|
|
194
194
|
/** Spawn a new process */
|
|
195
|
-
spawn: Vitest.
|
|
195
|
+
spawn: Vitest.Mock;
|
|
196
196
|
/** Execute command asynchronously */
|
|
197
|
-
exec: Vitest.
|
|
197
|
+
exec: Vitest.Mock;
|
|
198
198
|
/** Execute command synchronously */
|
|
199
|
-
execSync: Vitest.
|
|
199
|
+
execSync: Vitest.Mock;
|
|
200
200
|
/** Fork a child process */
|
|
201
|
-
fork: Vitest.
|
|
201
|
+
fork: Vitest.Mock;
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
204
|
* Mock timers interface for testing time-dependent code
|
|
@@ -220,17 +220,17 @@ export interface MockChildProcess {
|
|
|
220
220
|
*/
|
|
221
221
|
export interface MockTimers {
|
|
222
222
|
/** Schedule a timeout */
|
|
223
|
-
setTimeout: Vitest.
|
|
223
|
+
setTimeout: Vitest.Mock;
|
|
224
224
|
/** Clear a timeout */
|
|
225
|
-
clearTimeout: Vitest.
|
|
225
|
+
clearTimeout: Vitest.Mock;
|
|
226
226
|
/** Schedule an interval */
|
|
227
|
-
setInterval: Vitest.
|
|
227
|
+
setInterval: Vitest.Mock;
|
|
228
228
|
/** Clear an interval */
|
|
229
|
-
clearInterval: Vitest.
|
|
229
|
+
clearInterval: Vitest.Mock;
|
|
230
230
|
/** Schedule immediate execution */
|
|
231
|
-
setImmediate: Vitest.
|
|
231
|
+
setImmediate: Vitest.Mock;
|
|
232
232
|
/** Clear immediate execution */
|
|
233
|
-
clearImmediate: Vitest.
|
|
233
|
+
clearImmediate: Vitest.Mock;
|
|
234
234
|
/** Enable fake timers */
|
|
235
235
|
useFakeTimers: () => void;
|
|
236
236
|
/** Restore real timers */
|
|
@@ -265,39 +265,39 @@ export interface MockTimers {
|
|
|
265
265
|
*/
|
|
266
266
|
export interface MockEventEmitter {
|
|
267
267
|
/** Add event listener */
|
|
268
|
-
on: Vitest.
|
|
268
|
+
on: Vitest.Mock;
|
|
269
269
|
/** Add one-time event listener */
|
|
270
|
-
once: Vitest.
|
|
270
|
+
once: Vitest.Mock;
|
|
271
271
|
/** Remove event listener */
|
|
272
|
-
off: Vitest.
|
|
272
|
+
off: Vitest.Mock;
|
|
273
273
|
/** Emit event to listeners */
|
|
274
|
-
emit: Vitest.
|
|
274
|
+
emit: Vitest.Mock;
|
|
275
275
|
/** Emit event asynchronously */
|
|
276
|
-
emitAsync: Vitest.
|
|
276
|
+
emitAsync: Vitest.Mock;
|
|
277
277
|
/** Remove specific listener */
|
|
278
|
-
removeListener: Vitest.
|
|
278
|
+
removeListener: Vitest.Mock;
|
|
279
279
|
/** Remove all listeners for event */
|
|
280
|
-
removeAllListeners: Vitest.
|
|
280
|
+
removeAllListeners: Vitest.Mock;
|
|
281
281
|
/** Alias for on() */
|
|
282
|
-
addListener: Vitest.
|
|
282
|
+
addListener: Vitest.Mock;
|
|
283
283
|
/** Get listeners for event */
|
|
284
|
-
listeners: Vitest.
|
|
284
|
+
listeners: Vitest.Mock;
|
|
285
285
|
/** Count listeners for event */
|
|
286
|
-
listenerCount: Vitest.
|
|
286
|
+
listenerCount: Vitest.Mock;
|
|
287
287
|
/** Get all event names */
|
|
288
|
-
eventNames: Vitest.
|
|
288
|
+
eventNames: Vitest.Mock;
|
|
289
289
|
/** Set max listeners limit */
|
|
290
|
-
setMaxListeners: Vitest.
|
|
290
|
+
setMaxListeners: Vitest.Mock;
|
|
291
291
|
/** Get max listeners limit */
|
|
292
|
-
getMaxListeners: Vitest.
|
|
292
|
+
getMaxListeners: Vitest.Mock;
|
|
293
293
|
/** Wait for specific event */
|
|
294
|
-
waitForEvent: Vitest.
|
|
294
|
+
waitForEvent: Vitest.Mock;
|
|
295
295
|
/** Get raw listeners array */
|
|
296
|
-
rawListeners: Vitest.
|
|
296
|
+
rawListeners: Vitest.Mock;
|
|
297
297
|
/** Prepend listener to start of list */
|
|
298
|
-
prependListener: Vitest.
|
|
298
|
+
prependListener: Vitest.Mock;
|
|
299
299
|
/** Prepend one-time listener */
|
|
300
|
-
prependOnceListener: Vitest.
|
|
300
|
+
prependOnceListener: Vitest.Mock;
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* Mock logger interface matching NestJS Logger methods
|
|
@@ -318,21 +318,21 @@ export interface MockEventEmitter {
|
|
|
318
318
|
*/
|
|
319
319
|
export interface MockLogger {
|
|
320
320
|
/** Log info message */
|
|
321
|
-
log: Vitest.
|
|
321
|
+
log: Vitest.Mock;
|
|
322
322
|
/** Log error message */
|
|
323
|
-
error: Vitest.
|
|
323
|
+
error: Vitest.Mock;
|
|
324
324
|
/** Log warning message */
|
|
325
|
-
warn: Vitest.
|
|
325
|
+
warn: Vitest.Mock;
|
|
326
326
|
/** Log info message */
|
|
327
|
-
info: Vitest.
|
|
327
|
+
info: Vitest.Mock;
|
|
328
328
|
/** Log debug message */
|
|
329
|
-
debug: Vitest.
|
|
329
|
+
debug: Vitest.Mock;
|
|
330
330
|
/** Log verbose message */
|
|
331
|
-
verbose: Vitest.
|
|
331
|
+
verbose: Vitest.Mock;
|
|
332
332
|
/** Set log level */
|
|
333
|
-
setLevel: Vitest.
|
|
333
|
+
setLevel: Vitest.Mock;
|
|
334
334
|
/** Get log level */
|
|
335
|
-
getLevel: Vitest.
|
|
335
|
+
getLevel: Vitest.Mock;
|
|
336
336
|
}
|
|
337
337
|
/**
|
|
338
338
|
* NestJS common decorators and exceptions mock interface
|
|
@@ -355,27 +355,27 @@ export interface MockLogger {
|
|
|
355
355
|
*/
|
|
356
356
|
export interface NestJsCommonMocks {
|
|
357
357
|
/** Injectable decorator mock */
|
|
358
|
-
Injectable: Vitest.
|
|
358
|
+
Injectable: Vitest.Mock;
|
|
359
359
|
/** Inject decorator mock */
|
|
360
|
-
Inject: Vitest.
|
|
360
|
+
Inject: Vitest.Mock;
|
|
361
361
|
/** Optional decorator mock */
|
|
362
|
-
Optional: Vitest.
|
|
362
|
+
Optional: Vitest.Mock;
|
|
363
363
|
/** Logger class mock */
|
|
364
|
-
Logger: Vitest.
|
|
364
|
+
Logger: Vitest.Mock;
|
|
365
365
|
/** HttpException class mock */
|
|
366
|
-
HttpException: Vitest.
|
|
366
|
+
HttpException: Vitest.Mock;
|
|
367
367
|
/** HTTP status codes */
|
|
368
368
|
HttpStatus: Record<string, number>;
|
|
369
369
|
/** BadRequestException class mock */
|
|
370
|
-
BadRequestException: Vitest.
|
|
370
|
+
BadRequestException: Vitest.Mock;
|
|
371
371
|
/** NotFoundException class mock */
|
|
372
|
-
NotFoundException: Vitest.
|
|
372
|
+
NotFoundException: Vitest.Mock;
|
|
373
373
|
/** UnauthorizedException class mock */
|
|
374
|
-
UnauthorizedException: Vitest.
|
|
374
|
+
UnauthorizedException: Vitest.Mock;
|
|
375
375
|
/** ForbiddenException class mock */
|
|
376
|
-
ForbiddenException: Vitest.
|
|
376
|
+
ForbiddenException: Vitest.Mock;
|
|
377
377
|
/** InternalServerErrorException class mock */
|
|
378
|
-
InternalServerErrorException: Vitest.
|
|
378
|
+
InternalServerErrorException: Vitest.Mock;
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
381
381
|
* Mock CRUD service interface for testing data operations
|
|
@@ -392,15 +392,15 @@ export interface NestJsCommonMocks {
|
|
|
392
392
|
*/
|
|
393
393
|
export interface CrudServiceMock {
|
|
394
394
|
/** Find all entities */
|
|
395
|
-
findAll: Vitest.
|
|
395
|
+
findAll: Vitest.Mock;
|
|
396
396
|
/** Find one entity */
|
|
397
|
-
findOne: Vitest.
|
|
397
|
+
findOne: Vitest.Mock;
|
|
398
398
|
/** Create new entity */
|
|
399
|
-
create: Vitest.
|
|
399
|
+
create: Vitest.Mock;
|
|
400
400
|
/** Update existing entity */
|
|
401
|
-
update: Vitest.
|
|
401
|
+
update: Vitest.Mock;
|
|
402
402
|
/** Remove entity */
|
|
403
|
-
remove: Vitest.
|
|
403
|
+
remove: Vitest.Mock;
|
|
404
404
|
}
|
|
405
405
|
/**
|
|
406
406
|
* Mock NestJS testing module interface
|
|
@@ -490,7 +490,7 @@ export interface MockContextValue<T = unknown> {
|
|
|
490
490
|
/** Current context value */
|
|
491
491
|
value: T;
|
|
492
492
|
/** Function to update context value */
|
|
493
|
-
setValue: Vitest.
|
|
493
|
+
setValue: Vitest.Mock;
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* Mock React context provider interface
|
|
@@ -546,17 +546,17 @@ export interface MockProvider<T = unknown> {
|
|
|
546
546
|
*/
|
|
547
547
|
export interface MockRouter {
|
|
548
548
|
/** Navigate to new route */
|
|
549
|
-
push: Vitest.
|
|
549
|
+
push: Vitest.Mock;
|
|
550
550
|
/** Replace current route */
|
|
551
|
-
replace: Vitest.
|
|
551
|
+
replace: Vitest.Mock;
|
|
552
552
|
/** Go back in history */
|
|
553
|
-
back: Vitest.
|
|
553
|
+
back: Vitest.Mock;
|
|
554
554
|
/** Go forward in history */
|
|
555
|
-
forward: Vitest.
|
|
555
|
+
forward: Vitest.Mock;
|
|
556
556
|
/** Refresh current page */
|
|
557
|
-
refresh: Vitest.
|
|
557
|
+
refresh: Vitest.Mock;
|
|
558
558
|
/** Prefetch route */
|
|
559
|
-
prefetch: Vitest.
|
|
559
|
+
prefetch: Vitest.Mock;
|
|
560
560
|
/** Current pathname */
|
|
561
561
|
pathname: string;
|
|
562
562
|
/** Query parameters */
|
|
@@ -577,7 +577,7 @@ export interface MockRouter {
|
|
|
577
577
|
state: unknown;
|
|
578
578
|
};
|
|
579
579
|
/** Navigation history */
|
|
580
|
-
history: Array<
|
|
580
|
+
history: Array<HistoryEntry>;
|
|
581
581
|
}
|
|
582
582
|
/**
|
|
583
583
|
* Mock React hooks interface for testing hook behavior
|
|
@@ -597,21 +597,21 @@ export interface MockRouter {
|
|
|
597
597
|
*/
|
|
598
598
|
export interface MockHooks {
|
|
599
599
|
/** Mock useState hook */
|
|
600
|
-
useState: Vitest.
|
|
600
|
+
useState: Vitest.Mock;
|
|
601
601
|
/** Mock useEffect hook */
|
|
602
|
-
useEffect: Vitest.
|
|
602
|
+
useEffect: Vitest.Mock;
|
|
603
603
|
/** Mock useContext hook */
|
|
604
|
-
useContext: Vitest.
|
|
604
|
+
useContext: Vitest.Mock;
|
|
605
605
|
/** Mock useReducer hook */
|
|
606
|
-
useReducer: Vitest.
|
|
606
|
+
useReducer: Vitest.Mock;
|
|
607
607
|
/** Mock useCallback hook */
|
|
608
|
-
useCallback: Vitest.
|
|
608
|
+
useCallback: Vitest.Mock;
|
|
609
609
|
/** Mock useMemo hook */
|
|
610
|
-
useMemo: Vitest.
|
|
610
|
+
useMemo: Vitest.Mock;
|
|
611
611
|
/** Mock useRef hook */
|
|
612
|
-
useRef: Vitest.
|
|
612
|
+
useRef: Vitest.Mock;
|
|
613
613
|
/** Mock useLayoutEffect hook */
|
|
614
|
-
useLayoutEffect: Vitest.
|
|
614
|
+
useLayoutEffect: Vitest.Mock;
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* Mock fetch interface for testing HTTP requests
|
|
@@ -632,7 +632,7 @@ export interface MockHooks {
|
|
|
632
632
|
*/
|
|
633
633
|
export interface MockFetch {
|
|
634
634
|
/** Main fetch mock function */
|
|
635
|
-
mock: Vitest.
|
|
635
|
+
mock: Vitest.Mock;
|
|
636
636
|
/** Mock successful response */
|
|
637
637
|
mockResponse: (response: unknown, options?: ResponseInit) => void;
|
|
638
638
|
/** Mock error response */
|
|
@@ -660,17 +660,17 @@ export interface MockFetch {
|
|
|
660
660
|
*/
|
|
661
661
|
export interface MockLocalStorage {
|
|
662
662
|
/** Get item from storage */
|
|
663
|
-
getItem: Vitest.
|
|
663
|
+
getItem: Vitest.Mock;
|
|
664
664
|
/** Set item in storage */
|
|
665
|
-
setItem: Vitest.
|
|
665
|
+
setItem: Vitest.Mock;
|
|
666
666
|
/** Remove item from storage */
|
|
667
|
-
removeItem: Vitest.
|
|
667
|
+
removeItem: Vitest.Mock;
|
|
668
668
|
/** Clear all storage */
|
|
669
|
-
clear: Vitest.
|
|
669
|
+
clear: Vitest.Mock;
|
|
670
670
|
/** Number of items in storage */
|
|
671
671
|
length: number;
|
|
672
672
|
/** Get key at index */
|
|
673
|
-
key: Vitest.
|
|
673
|
+
key: Vitest.Mock;
|
|
674
674
|
}
|
|
675
675
|
/**
|
|
676
676
|
* Mock IntersectionObserver instance interface
|
|
@@ -696,11 +696,11 @@ export interface MockIntersectionObserverInstance {
|
|
|
696
696
|
/** Set of observed elements */
|
|
697
697
|
elements: Set<Element>;
|
|
698
698
|
/** Start observing element */
|
|
699
|
-
observe: Vitest.
|
|
699
|
+
observe: Vitest.Mock;
|
|
700
700
|
/** Stop observing element */
|
|
701
|
-
unobserve: Vitest.
|
|
701
|
+
unobserve: Vitest.Mock;
|
|
702
702
|
/** Disconnect all observations */
|
|
703
|
-
disconnect: Vitest.
|
|
703
|
+
disconnect: Vitest.Mock;
|
|
704
704
|
/** Manually trigger intersection entries */
|
|
705
705
|
trigger: (entries: IntersectionObserverEntry[]) => void;
|
|
706
706
|
}
|
|
@@ -722,7 +722,7 @@ export interface MockIntersectionObserverInstance {
|
|
|
722
722
|
*/
|
|
723
723
|
export interface MockIntersectionObserver {
|
|
724
724
|
/** IntersectionObserver constructor mock */
|
|
725
|
-
MockIntersectionObserver: Vitest.
|
|
725
|
+
MockIntersectionObserver: Vitest.Mock;
|
|
726
726
|
/** Array of observer instances */
|
|
727
727
|
instances: MockIntersectionObserverInstance[];
|
|
728
728
|
/** Trigger intersection for specific entries */
|
|
@@ -732,11 +732,11 @@ export interface MockIntersectionObserver {
|
|
|
732
732
|
/** Reset all observers */
|
|
733
733
|
reset: () => void;
|
|
734
734
|
/** Observe element mock */
|
|
735
|
-
observe: Vitest.
|
|
735
|
+
observe: Vitest.Mock;
|
|
736
736
|
/** Unobserve element mock */
|
|
737
|
-
unobserve: Vitest.
|
|
737
|
+
unobserve: Vitest.Mock;
|
|
738
738
|
/** Disconnect observer mock */
|
|
739
|
-
disconnect: Vitest.
|
|
739
|
+
disconnect: Vitest.Mock;
|
|
740
740
|
/** Current observer callback */
|
|
741
741
|
callback: ((entries: IntersectionObserverEntry[]) => void) | null;
|
|
742
742
|
}
|
|
@@ -759,27 +759,27 @@ export interface MockIntersectionObserver {
|
|
|
759
759
|
*/
|
|
760
760
|
export interface MockNextRouter extends Omit<NextRouter.NextRouter, 'push' | 'replace' | 'reload' | 'back' | 'forward' | 'prefetch' | 'beforePopState' | 'events'> {
|
|
761
761
|
/** Navigate to new route */
|
|
762
|
-
push: Vitest.
|
|
762
|
+
push: Vitest.Mock;
|
|
763
763
|
/** Replace current route */
|
|
764
|
-
replace: Vitest.
|
|
764
|
+
replace: Vitest.Mock;
|
|
765
765
|
/** Reload current page */
|
|
766
|
-
reload: Vitest.
|
|
766
|
+
reload: Vitest.Mock;
|
|
767
767
|
/** Go back in history */
|
|
768
|
-
back: Vitest.
|
|
768
|
+
back: Vitest.Mock;
|
|
769
769
|
/** Go forward in history */
|
|
770
|
-
forward: Vitest.
|
|
770
|
+
forward: Vitest.Mock;
|
|
771
771
|
/** Prefetch route */
|
|
772
|
-
prefetch: Vitest.
|
|
772
|
+
prefetch: Vitest.Mock;
|
|
773
773
|
/** Set before pop state handler */
|
|
774
|
-
beforePopState: Vitest.
|
|
774
|
+
beforePopState: Vitest.Mock;
|
|
775
775
|
/** Router events */
|
|
776
776
|
events: {
|
|
777
777
|
/** Add event listener */
|
|
778
|
-
on: Vitest.
|
|
778
|
+
on: Vitest.Mock;
|
|
779
779
|
/** Remove event listener */
|
|
780
|
-
off: Vitest.
|
|
780
|
+
off: Vitest.Mock;
|
|
781
781
|
/** Emit router event */
|
|
782
|
-
emit: Vitest.
|
|
782
|
+
emit: Vitest.Mock;
|
|
783
783
|
};
|
|
784
784
|
pathname: string;
|
|
785
785
|
route: string;
|
|
@@ -855,23 +855,23 @@ export type MockNextApiRequest = Partial<Next.NextApiRequest> & {
|
|
|
855
855
|
*/
|
|
856
856
|
export interface MockNextApiResponse {
|
|
857
857
|
/** Set response status */
|
|
858
|
-
status: Vitest.
|
|
858
|
+
status: Vitest.Mock;
|
|
859
859
|
/** Send JSON response */
|
|
860
|
-
json: Vitest.
|
|
860
|
+
json: Vitest.Mock;
|
|
861
861
|
/** Send response */
|
|
862
|
-
send: Vitest.
|
|
862
|
+
send: Vitest.Mock;
|
|
863
863
|
/** Redirect response */
|
|
864
|
-
redirect: Vitest.
|
|
864
|
+
redirect: Vitest.Mock;
|
|
865
865
|
/** Set response header */
|
|
866
|
-
setHeader: Vitest.
|
|
866
|
+
setHeader: Vitest.Mock;
|
|
867
867
|
/** Get response header */
|
|
868
|
-
getHeader: Vitest.
|
|
868
|
+
getHeader: Vitest.Mock;
|
|
869
869
|
/** Remove response header */
|
|
870
|
-
removeHeader: Vitest.
|
|
870
|
+
removeHeader: Vitest.Mock;
|
|
871
871
|
/** Write to response */
|
|
872
|
-
write: Vitest.
|
|
872
|
+
write: Vitest.Mock;
|
|
873
873
|
/** End response */
|
|
874
|
-
end: Vitest.
|
|
874
|
+
end: Vitest.Mock;
|
|
875
875
|
/** Current status code */
|
|
876
876
|
statusCode: number;
|
|
877
877
|
/** Current status message */
|
|
@@ -928,21 +928,21 @@ export type MockGetStaticPropsContext = Next.GetStaticPropsContext;
|
|
|
928
928
|
*/
|
|
929
929
|
export interface MockSearchParams {
|
|
930
930
|
/** Get parameter value */
|
|
931
|
-
get: Vitest.
|
|
931
|
+
get: Vitest.Mock;
|
|
932
932
|
/** Get all values for parameter */
|
|
933
|
-
getAll: Vitest.
|
|
933
|
+
getAll: Vitest.Mock;
|
|
934
934
|
/** Check if parameter exists */
|
|
935
|
-
has: Vitest.
|
|
935
|
+
has: Vitest.Mock;
|
|
936
936
|
/** Get all parameter keys */
|
|
937
|
-
keys: Vitest.
|
|
937
|
+
keys: Vitest.Mock;
|
|
938
938
|
/** Get all parameter values */
|
|
939
|
-
values: Vitest.
|
|
939
|
+
values: Vitest.Mock;
|
|
940
940
|
/** Get all key-value entries */
|
|
941
|
-
entries: Vitest.
|
|
941
|
+
entries: Vitest.Mock;
|
|
942
942
|
/** Iterate over parameters */
|
|
943
|
-
forEach: Vitest.
|
|
943
|
+
forEach: Vitest.Mock;
|
|
944
944
|
/** Convert to string */
|
|
945
|
-
toString: Vitest.
|
|
945
|
+
toString: Vitest.Mock;
|
|
946
946
|
}
|
|
947
947
|
/**
|
|
948
948
|
* Mock Next.js environment variables interface
|
|
@@ -1040,19 +1040,19 @@ export interface MockHttpRequest {
|
|
|
1040
1040
|
remotePort: number;
|
|
1041
1041
|
};
|
|
1042
1042
|
/** Add event listener */
|
|
1043
|
-
on?: Vitest.
|
|
1043
|
+
on?: Vitest.Mock;
|
|
1044
1044
|
/** Add one-time event listener */
|
|
1045
|
-
once?: Vitest.
|
|
1045
|
+
once?: Vitest.Mock;
|
|
1046
1046
|
/** Emit event */
|
|
1047
|
-
emit?: Vitest.
|
|
1047
|
+
emit?: Vitest.Mock;
|
|
1048
1048
|
/** Pipe to stream */
|
|
1049
|
-
pipe?: Vitest.
|
|
1049
|
+
pipe?: Vitest.Mock;
|
|
1050
1050
|
/** Unpipe from stream */
|
|
1051
|
-
unpipe?: Vitest.
|
|
1051
|
+
unpipe?: Vitest.Mock;
|
|
1052
1052
|
/** Pause stream */
|
|
1053
|
-
pause?: Vitest.
|
|
1053
|
+
pause?: Vitest.Mock;
|
|
1054
1054
|
/** Resume stream */
|
|
1055
|
-
resume?: Vitest.
|
|
1055
|
+
resume?: Vitest.Mock;
|
|
1056
1056
|
}
|
|
1057
1057
|
/**
|
|
1058
1058
|
* Mock HTTP response interface for testing HTTP handlers
|
|
@@ -1076,31 +1076,31 @@ export interface MockHttpResponse {
|
|
|
1076
1076
|
/** Current status message */
|
|
1077
1077
|
statusMessage: string;
|
|
1078
1078
|
/** Set status code */
|
|
1079
|
-
status: Vitest.
|
|
1079
|
+
status: Vitest.Mock;
|
|
1080
1080
|
/** Send JSON response */
|
|
1081
|
-
json: Vitest.
|
|
1081
|
+
json: Vitest.Mock;
|
|
1082
1082
|
/** Send response */
|
|
1083
|
-
send: Vitest.
|
|
1083
|
+
send: Vitest.Mock;
|
|
1084
1084
|
/** Set response header */
|
|
1085
|
-
setHeader: Vitest.
|
|
1085
|
+
setHeader: Vitest.Mock;
|
|
1086
1086
|
/** Get response header */
|
|
1087
|
-
getHeader: Vitest.
|
|
1087
|
+
getHeader: Vitest.Mock;
|
|
1088
1088
|
/** Remove response header */
|
|
1089
|
-
removeHeader: Vitest.
|
|
1089
|
+
removeHeader: Vitest.Mock;
|
|
1090
1090
|
/** Write to response */
|
|
1091
|
-
write: Vitest.
|
|
1091
|
+
write: Vitest.Mock;
|
|
1092
1092
|
/** End response */
|
|
1093
|
-
end: Vitest.
|
|
1093
|
+
end: Vitest.Mock;
|
|
1094
1094
|
/** Write response head */
|
|
1095
|
-
writeHead?: Vitest.
|
|
1095
|
+
writeHead?: Vitest.Mock;
|
|
1096
1096
|
/** Redirect response */
|
|
1097
|
-
redirect?: Vitest.
|
|
1097
|
+
redirect?: Vitest.Mock;
|
|
1098
1098
|
/** Add event listener */
|
|
1099
|
-
on?: Vitest.
|
|
1099
|
+
on?: Vitest.Mock;
|
|
1100
1100
|
/** Add one-time event listener */
|
|
1101
|
-
once?: Vitest.
|
|
1101
|
+
once?: Vitest.Mock;
|
|
1102
1102
|
/** Emit event */
|
|
1103
|
-
emit?: Vitest.
|
|
1103
|
+
emit?: Vitest.Mock;
|
|
1104
1104
|
/** Whether response is finished */
|
|
1105
1105
|
finished?: boolean;
|
|
1106
1106
|
/** Whether headers are sent */
|
|
@@ -1121,7 +1121,7 @@ export interface MockHttpResponse {
|
|
|
1121
1121
|
* };
|
|
1122
1122
|
* ```
|
|
1123
1123
|
*/
|
|
1124
|
-
export interface
|
|
1124
|
+
export interface HistoryEntry {
|
|
1125
1125
|
/** URL pathname */
|
|
1126
1126
|
pathname: string;
|
|
1127
1127
|
/** URL search string */
|
|
@@ -1171,7 +1171,7 @@ export interface MiddlewareContext {
|
|
|
1171
1171
|
/** Mock HTTP response */
|
|
1172
1172
|
res: MockHttpResponse;
|
|
1173
1173
|
/** Next function mock */
|
|
1174
|
-
next: Vitest.
|
|
1174
|
+
next: Vitest.Mock;
|
|
1175
1175
|
}
|
|
1176
1176
|
/**
|
|
1177
1177
|
* Options for stream piping operations
|
|
@@ -1226,11 +1226,11 @@ export interface NextLinkChildProps {
|
|
|
1226
1226
|
*/
|
|
1227
1227
|
export interface ErrorHandlerMock {
|
|
1228
1228
|
/** Error event handler */
|
|
1229
|
-
onError: Vitest.
|
|
1229
|
+
onError: Vitest.Mock;
|
|
1230
1230
|
/** Catch block handler */
|
|
1231
|
-
onCatch: Vitest.
|
|
1231
|
+
onCatch: Vitest.Mock;
|
|
1232
1232
|
/** Finally block handler */
|
|
1233
|
-
onFinally: Vitest.
|
|
1233
|
+
onFinally: Vitest.Mock;
|
|
1234
1234
|
/** Reset all handlers */
|
|
1235
1235
|
reset: () => void;
|
|
1236
1236
|
}
|
|
@@ -1322,21 +1322,21 @@ export interface TimerCallbackEntry {
|
|
|
1322
1322
|
*/
|
|
1323
1323
|
export interface MockHttpServer {
|
|
1324
1324
|
/** Start listening on port */
|
|
1325
|
-
listen: Vitest.
|
|
1325
|
+
listen: Vitest.Mock;
|
|
1326
1326
|
/** Close server */
|
|
1327
|
-
close: Vitest.
|
|
1327
|
+
close: Vitest.Mock;
|
|
1328
1328
|
/** Get server address */
|
|
1329
|
-
address: Vitest.
|
|
1329
|
+
address: Vitest.Mock;
|
|
1330
1330
|
/** Active connections */
|
|
1331
1331
|
connections: Set<unknown>;
|
|
1332
1332
|
/** Get connection count */
|
|
1333
|
-
getConnections: Vitest.
|
|
1333
|
+
getConnections: Vitest.Mock;
|
|
1334
1334
|
/** Add event listener */
|
|
1335
|
-
on: Vitest.
|
|
1335
|
+
on: Vitest.Mock;
|
|
1336
1336
|
/** Add one-time event listener */
|
|
1337
|
-
once: Vitest.
|
|
1337
|
+
once: Vitest.Mock;
|
|
1338
1338
|
/** Emit server event */
|
|
1339
|
-
emit: Vitest.
|
|
1339
|
+
emit: Vitest.Mock;
|
|
1340
1340
|
}
|
|
1341
1341
|
/**
|
|
1342
1342
|
* Mock readable stream interface extending EventEmitter
|
|
@@ -1498,7 +1498,7 @@ export interface NestJsModuleMock {
|
|
|
1498
1498
|
*/
|
|
1499
1499
|
export type CreateStatefulCounterMockReturn = StatefulMock<{
|
|
1500
1500
|
value: number;
|
|
1501
|
-
}, Record<string, Vitest.
|
|
1501
|
+
}, Record<string, Vitest.Mock>>;
|
|
1502
1502
|
/**
|
|
1503
1503
|
* Base interface for stateful mocks with state management
|
|
1504
1504
|
*
|
|
@@ -1571,7 +1571,7 @@ export interface StatefulMockOptions<TState> {
|
|
|
1571
1571
|
/**
|
|
1572
1572
|
* Type definition for createMockUseRouter function return
|
|
1573
1573
|
*/
|
|
1574
|
-
export type CreateMockUseRouterReturn = Vitest.
|
|
1574
|
+
export type CreateMockUseRouterReturn = Vitest.Mock;
|
|
1575
1575
|
/**
|
|
1576
1576
|
* Type definition for createMockWebSocket function return
|
|
1577
1577
|
*/
|
|
@@ -1582,24 +1582,24 @@ export interface CreateMockWebSocketReturn {
|
|
|
1582
1582
|
readyState: number;
|
|
1583
1583
|
bufferedAmount: number;
|
|
1584
1584
|
binaryType: 'blob' | 'arraybuffer';
|
|
1585
|
-
send: Vitest.
|
|
1586
|
-
close: Vitest.
|
|
1587
|
-
ping: Vitest.
|
|
1588
|
-
pong: Vitest.
|
|
1589
|
-
terminate: Vitest.
|
|
1585
|
+
send: Vitest.Mock;
|
|
1586
|
+
close: Vitest.Mock;
|
|
1587
|
+
ping: Vitest.Mock;
|
|
1588
|
+
pong: Vitest.Mock;
|
|
1589
|
+
terminate: Vitest.Mock;
|
|
1590
1590
|
messages: unknown[];
|
|
1591
1591
|
simulateMessage: (data: unknown) => void;
|
|
1592
1592
|
simulateError: (error: Error) => void;
|
|
1593
1593
|
simulateClose: (code?: number, reason?: string) => void;
|
|
1594
1594
|
simulateOpen: () => void;
|
|
1595
|
-
on: Vitest.
|
|
1596
|
-
off: Vitest.
|
|
1597
|
-
emit: Vitest.
|
|
1598
|
-
addListener: Vitest.
|
|
1599
|
-
removeListener: Vitest.
|
|
1600
|
-
removeAllListeners: Vitest.
|
|
1601
|
-
listeners: Vitest.
|
|
1602
|
-
listenerCount: Vitest.
|
|
1595
|
+
on: Vitest.Mock;
|
|
1596
|
+
off: Vitest.Mock;
|
|
1597
|
+
emit: Vitest.Mock;
|
|
1598
|
+
addListener: Vitest.Mock;
|
|
1599
|
+
removeListener: Vitest.Mock;
|
|
1600
|
+
removeAllListeners: Vitest.Mock;
|
|
1601
|
+
listeners: Vitest.Mock;
|
|
1602
|
+
listenerCount: Vitest.Mock;
|
|
1603
1603
|
}
|
|
1604
1604
|
/**
|
|
1605
1605
|
* Type definition for middlewareUtils.createMockNextRequest function
|
|
@@ -1623,9 +1623,9 @@ export type CreateMockNextRequestFunction = (url: string, options?: {
|
|
|
1623
1623
|
href: string;
|
|
1624
1624
|
};
|
|
1625
1625
|
cookies: {
|
|
1626
|
-
get: Vitest.
|
|
1627
|
-
set: Vitest.
|
|
1628
|
-
delete: Vitest.
|
|
1626
|
+
get: Vitest.Mock;
|
|
1627
|
+
set: Vitest.Mock;
|
|
1628
|
+
delete: Vitest.Mock;
|
|
1629
1629
|
};
|
|
1630
1630
|
geo: {
|
|
1631
1631
|
city: string;
|
|
@@ -1643,22 +1643,22 @@ export interface CreateMockWebSocketServerReturn {
|
|
|
1643
1643
|
port: number;
|
|
1644
1644
|
host: string;
|
|
1645
1645
|
maxClients: number;
|
|
1646
|
-
handleUpgrade: Vitest.
|
|
1647
|
-
shouldHandle: Vitest.
|
|
1648
|
-
close: Vitest.
|
|
1646
|
+
handleUpgrade: Vitest.Mock;
|
|
1647
|
+
shouldHandle: Vitest.Mock;
|
|
1648
|
+
close: Vitest.Mock;
|
|
1649
1649
|
addClient: (client: CreateMockWebSocketReturn) => void;
|
|
1650
1650
|
removeClient: (client: CreateMockWebSocketReturn) => void;
|
|
1651
1651
|
simulateConnection: (clientId?: string) => CreateMockWebSocketReturn;
|
|
1652
1652
|
simulateBroadcast: (data: unknown, excludeClient?: string) => void;
|
|
1653
1653
|
simulateClientDisconnect: (clientId: string) => void;
|
|
1654
|
-
on: Vitest.
|
|
1655
|
-
off: Vitest.
|
|
1656
|
-
emit: Vitest.
|
|
1657
|
-
addListener: Vitest.
|
|
1658
|
-
removeListener: Vitest.
|
|
1659
|
-
removeAllListeners: Vitest.
|
|
1660
|
-
listeners: Vitest.
|
|
1661
|
-
listenerCount: Vitest.
|
|
1654
|
+
on: Vitest.Mock;
|
|
1655
|
+
off: Vitest.Mock;
|
|
1656
|
+
emit: Vitest.Mock;
|
|
1657
|
+
addListener: Vitest.Mock;
|
|
1658
|
+
removeListener: Vitest.Mock;
|
|
1659
|
+
removeAllListeners: Vitest.Mock;
|
|
1660
|
+
listeners: Vitest.Mock;
|
|
1661
|
+
listenerCount: Vitest.Mock;
|
|
1662
1662
|
}
|
|
1663
1663
|
/**
|
|
1664
1664
|
* Console mock with advanced capture and filtering
|
|
@@ -1666,11 +1666,11 @@ export interface CreateMockWebSocketServerReturn {
|
|
|
1666
1666
|
* @public
|
|
1667
1667
|
*/
|
|
1668
1668
|
export interface AdvancedConsoleMock {
|
|
1669
|
-
log: Vitest.
|
|
1670
|
-
warn: Vitest.
|
|
1671
|
-
error: Vitest.
|
|
1672
|
-
info: Vitest.
|
|
1673
|
-
debug: Vitest.
|
|
1669
|
+
log: Vitest.Mock;
|
|
1670
|
+
warn: Vitest.Mock;
|
|
1671
|
+
error: Vitest.Mock;
|
|
1672
|
+
info: Vitest.Mock;
|
|
1673
|
+
debug: Vitest.Mock;
|
|
1674
1674
|
logs: string[];
|
|
1675
1675
|
warnings: string[];
|
|
1676
1676
|
errors: string[];
|
|
@@ -1694,256 +1694,487 @@ export interface AdvancedConsoleMock {
|
|
|
1694
1694
|
getLastError: () => string | undefined;
|
|
1695
1695
|
}
|
|
1696
1696
|
/**
|
|
1697
|
-
* Mock FormData implementation
|
|
1698
|
-
*
|
|
1697
|
+
* Mock FormData implementation for testing form data handling.
|
|
1698
|
+
* Simulates browser FormData API for testing file uploads and form submissions.
|
|
1699
|
+
*
|
|
1700
|
+
* @example
|
|
1701
|
+
* ```typescript
|
|
1702
|
+
* const mockFormData: MockFormData = {
|
|
1703
|
+
* append: vi.fn(),
|
|
1704
|
+
* delete: vi.fn(),
|
|
1705
|
+
* get: vi.fn().mockReturnValue('value'),
|
|
1706
|
+
* getAll: vi.fn().mockReturnValue(['value1', 'value2']),
|
|
1707
|
+
* has: vi.fn().mockReturnValue(true),
|
|
1708
|
+
* set: vi.fn(),
|
|
1709
|
+
* entries: vi.fn(),
|
|
1710
|
+
* keys: vi.fn(),
|
|
1711
|
+
* values: vi.fn()
|
|
1712
|
+
* };
|
|
1713
|
+
*
|
|
1714
|
+
* // Test form data operations
|
|
1715
|
+
* mockFormData.append('file', new Blob(['content']));
|
|
1716
|
+
* mockFormData.set('field', 'value');
|
|
1717
|
+
* ```
|
|
1699
1718
|
*/
|
|
1700
1719
|
export interface MockFormData {
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
set: Vitest.MockInstance;
|
|
1713
|
-
/** Iterate entries */
|
|
1714
|
-
entries: Vitest.MockInstance;
|
|
1715
|
-
/** Iterate keys */
|
|
1716
|
-
keys: Vitest.MockInstance;
|
|
1717
|
-
/** Iterate values */
|
|
1718
|
-
values: Vitest.MockInstance;
|
|
1720
|
+
append: Vitest.Mock;
|
|
1721
|
+
delete: Vitest.Mock;
|
|
1722
|
+
get: Vitest.Mock;
|
|
1723
|
+
getAll: Vitest.Mock;
|
|
1724
|
+
has: Vitest.Mock;
|
|
1725
|
+
set: Vitest.Mock;
|
|
1726
|
+
entries: Vitest.Mock;
|
|
1727
|
+
keys: Vitest.Mock;
|
|
1728
|
+
values: Vitest.Mock;
|
|
1729
|
+
forEach: Vitest.Mock;
|
|
1730
|
+
_entries: Map<string, Array<string | Blob>>;
|
|
1719
1731
|
}
|
|
1720
1732
|
/**
|
|
1721
|
-
*
|
|
1722
|
-
*
|
|
1733
|
+
* Mock Axios implementation for testing HTTP requests.
|
|
1734
|
+
* Provides mocked versions of all Axios methods and interceptors.
|
|
1735
|
+
*
|
|
1736
|
+
* @example
|
|
1737
|
+
* ```typescript
|
|
1738
|
+
* const mockAxios: MockAxios = {
|
|
1739
|
+
* get: vi.fn().mockResolvedValue({ data: { users: [] } }),
|
|
1740
|
+
* post: vi.fn().mockResolvedValue({ data: { id: 1 } }),
|
|
1741
|
+
* put: vi.fn().mockResolvedValue({ data: { updated: true } }),
|
|
1742
|
+
* patch: vi.fn().mockResolvedValue({ data: { patched: true } }),
|
|
1743
|
+
* delete: vi.fn().mockResolvedValue({ data: { deleted: true } }),
|
|
1744
|
+
* head: vi.fn().mockResolvedValue({ headers: {} }),
|
|
1745
|
+
* options: vi.fn().mockResolvedValue({ data: ['GET', 'POST'] }),
|
|
1746
|
+
* interceptors: {
|
|
1747
|
+
* request: { use: vi.fn(), eject: vi.fn() },
|
|
1748
|
+
* response: { use: vi.fn(), eject: vi.fn() }
|
|
1749
|
+
* }
|
|
1750
|
+
* };
|
|
1751
|
+
* ```
|
|
1723
1752
|
*/
|
|
1724
1753
|
export interface MockAxios {
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1754
|
+
get: Vitest.Mock;
|
|
1755
|
+
post: Vitest.Mock;
|
|
1756
|
+
put: Vitest.Mock;
|
|
1757
|
+
patch: Vitest.Mock;
|
|
1758
|
+
delete: Vitest.Mock;
|
|
1759
|
+
head: Vitest.Mock;
|
|
1760
|
+
options: Vitest.Mock;
|
|
1761
|
+
request: Vitest.Mock;
|
|
1762
|
+
create: Vitest.Mock;
|
|
1763
|
+
defaults: {
|
|
1764
|
+
headers: {
|
|
1765
|
+
common: Record<string, string>;
|
|
1766
|
+
get: Record<string, string>;
|
|
1767
|
+
post: Record<string, string>;
|
|
1768
|
+
put: Record<string, string>;
|
|
1769
|
+
patch: Record<string, string>;
|
|
1770
|
+
delete: Record<string, string>;
|
|
1771
|
+
};
|
|
1772
|
+
baseURL?: string;
|
|
1773
|
+
timeout?: number;
|
|
1774
|
+
withCredentials?: boolean;
|
|
1775
|
+
};
|
|
1740
1776
|
interceptors: {
|
|
1741
1777
|
request: {
|
|
1742
|
-
use: Vitest.
|
|
1743
|
-
eject: Vitest.
|
|
1778
|
+
use: Vitest.Mock;
|
|
1779
|
+
eject: Vitest.Mock;
|
|
1780
|
+
handlers: Array<{
|
|
1781
|
+
fulfilled: Function;
|
|
1782
|
+
rejected?: Function;
|
|
1783
|
+
}>;
|
|
1744
1784
|
};
|
|
1745
1785
|
response: {
|
|
1746
|
-
use: Vitest.
|
|
1747
|
-
eject: Vitest.
|
|
1786
|
+
use: Vitest.Mock;
|
|
1787
|
+
eject: Vitest.Mock;
|
|
1788
|
+
handlers: Array<{
|
|
1789
|
+
fulfilled: Function;
|
|
1790
|
+
rejected?: Function;
|
|
1791
|
+
}>;
|
|
1748
1792
|
};
|
|
1749
1793
|
};
|
|
1794
|
+
mockResponse: Vitest.Mock;
|
|
1795
|
+
mockError: Vitest.Mock;
|
|
1796
|
+
mockResponseOnce: Vitest.Mock;
|
|
1797
|
+
mockErrorOnce: Vitest.Mock;
|
|
1798
|
+
reset: Vitest.Mock;
|
|
1750
1799
|
}
|
|
1751
1800
|
/**
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1801
|
+
* Mock Headers implementation for testing HTTP headers.
|
|
1802
|
+
* Simulates the Fetch API Headers interface.
|
|
1803
|
+
*
|
|
1804
|
+
* @example
|
|
1805
|
+
* ```typescript
|
|
1806
|
+
* const mockHeaders: MockHeaders = {
|
|
1807
|
+
* append: vi.fn(),
|
|
1808
|
+
* delete: vi.fn(),
|
|
1809
|
+
* get: vi.fn().mockReturnValue('application/json'),
|
|
1810
|
+
* has: vi.fn().mockReturnValue(true),
|
|
1811
|
+
* set: vi.fn(),
|
|
1812
|
+
* entries: vi.fn(),
|
|
1813
|
+
* keys: vi.fn(),
|
|
1814
|
+
* values: vi.fn()
|
|
1815
|
+
* };
|
|
1816
|
+
*
|
|
1817
|
+
* // Test header operations
|
|
1818
|
+
* mockHeaders.set('Content-Type', 'application/json');
|
|
1819
|
+
* mockHeaders.append('Authorization', 'Bearer token');
|
|
1820
|
+
* ```
|
|
1754
1821
|
*/
|
|
1755
1822
|
export interface MockHeaders {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
/** Iterate entries */
|
|
1767
|
-
entries: Vitest.MockInstance;
|
|
1768
|
-
/** Iterate keys */
|
|
1769
|
-
keys: Vitest.MockInstance;
|
|
1770
|
-
/** Iterate values */
|
|
1771
|
-
values: Vitest.MockInstance;
|
|
1823
|
+
append: Vitest.Mock;
|
|
1824
|
+
delete: Vitest.Mock;
|
|
1825
|
+
get: Vitest.Mock;
|
|
1826
|
+
has: Vitest.Mock;
|
|
1827
|
+
set: Vitest.Mock;
|
|
1828
|
+
entries: Vitest.Mock;
|
|
1829
|
+
keys: Vitest.Mock;
|
|
1830
|
+
values: Vitest.Mock;
|
|
1831
|
+
forEach: Vitest.Mock;
|
|
1832
|
+
_headers: Map<string, string>;
|
|
1772
1833
|
}
|
|
1773
1834
|
/**
|
|
1774
|
-
*
|
|
1775
|
-
*
|
|
1835
|
+
* Mock cookie manager for testing cookie operations.
|
|
1836
|
+
* Provides methods for cookie manipulation in tests.
|
|
1837
|
+
*
|
|
1838
|
+
* @example
|
|
1839
|
+
* ```typescript
|
|
1840
|
+
* const mockCookie: MockCookie = {
|
|
1841
|
+
* get: vi.fn().mockReturnValue('sessionId=abc123'),
|
|
1842
|
+
* set: vi.fn(),
|
|
1843
|
+
* delete: vi.fn(),
|
|
1844
|
+
* getAll: vi.fn().mockReturnValue({ sessionId: 'abc123', theme: 'dark' }),
|
|
1845
|
+
* clear: vi.fn(),
|
|
1846
|
+
* parse: vi.fn().mockImplementation((str) => ({
|
|
1847
|
+
* sessionId: 'abc123'
|
|
1848
|
+
* })),
|
|
1849
|
+
* serialize: vi.fn().mockReturnValue('sessionId=abc123; Path=/; HttpOnly')
|
|
1850
|
+
* };
|
|
1851
|
+
* ```
|
|
1776
1852
|
*/
|
|
1777
1853
|
export interface MockCookie {
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
/** Serialize cookie */
|
|
1791
|
-
serialize: Vitest.MockInstance;
|
|
1854
|
+
get: Vitest.Mock;
|
|
1855
|
+
set: Vitest.Mock;
|
|
1856
|
+
delete: Vitest.Mock;
|
|
1857
|
+
clear: Vitest.Mock;
|
|
1858
|
+
getAll: Vitest.Mock;
|
|
1859
|
+
has: Vitest.Mock;
|
|
1860
|
+
serialize: Vitest.Mock;
|
|
1861
|
+
parse: Vitest.Mock;
|
|
1862
|
+
_cookies: Map<string, {
|
|
1863
|
+
value: string;
|
|
1864
|
+
options?: unknown;
|
|
1865
|
+
}>;
|
|
1792
1866
|
}
|
|
1793
1867
|
/**
|
|
1794
|
-
*
|
|
1795
|
-
*
|
|
1868
|
+
* Mock session implementation for testing session management.
|
|
1869
|
+
* Provides methods for session storage and lifecycle.
|
|
1870
|
+
*
|
|
1871
|
+
* @example
|
|
1872
|
+
* ```typescript
|
|
1873
|
+
* const mockSession: MockSession = {
|
|
1874
|
+
* get: vi.fn().mockReturnValue({ userId: '123' }),
|
|
1875
|
+
* set: vi.fn(),
|
|
1876
|
+
* delete: vi.fn(),
|
|
1877
|
+
* clear: vi.fn(),
|
|
1878
|
+
* save: vi.fn().mockResolvedValue(undefined),
|
|
1879
|
+
* destroy: vi.fn().mockResolvedValue(undefined),
|
|
1880
|
+
* touch: vi.fn()
|
|
1881
|
+
* };
|
|
1882
|
+
*
|
|
1883
|
+
* // Test session operations
|
|
1884
|
+
* mockSession.set('userId', '123');
|
|
1885
|
+
* await mockSession.save();
|
|
1886
|
+
* ```
|
|
1796
1887
|
*/
|
|
1797
1888
|
export interface MockSession {
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1889
|
+
get: Vitest.Mock;
|
|
1890
|
+
set: Vitest.Mock;
|
|
1891
|
+
delete: Vitest.Mock;
|
|
1892
|
+
clear: Vitest.Mock;
|
|
1893
|
+
has: Vitest.Mock;
|
|
1894
|
+
save: Vitest.Mock;
|
|
1895
|
+
destroy: Vitest.Mock;
|
|
1896
|
+
regenerate: Vitest.Mock;
|
|
1897
|
+
touch: Vitest.Mock;
|
|
1898
|
+
reload: Vitest.Mock;
|
|
1899
|
+
id: string;
|
|
1900
|
+
_data: Record<string, unknown>;
|
|
1901
|
+
_dirty: boolean;
|
|
1902
|
+
_destroyed: boolean;
|
|
1812
1903
|
}
|
|
1813
1904
|
/**
|
|
1814
|
-
*
|
|
1815
|
-
*
|
|
1905
|
+
* Mock HTTP interceptor for testing request/response interception.
|
|
1906
|
+
* Allows intercepting and modifying HTTP traffic in tests.
|
|
1907
|
+
*
|
|
1908
|
+
* @example
|
|
1909
|
+
* ```typescript
|
|
1910
|
+
* const mockInterceptor: MockInterceptor = {
|
|
1911
|
+
* intercept: vi.fn().mockReturnThis(),
|
|
1912
|
+
* capture: vi.fn().mockReturnThis(),
|
|
1913
|
+
* reply: vi.fn().mockImplementation((status, data) => ({ status, data })),
|
|
1914
|
+
* status: vi.fn().mockReturnThis(),
|
|
1915
|
+
* headers: vi.fn().mockReturnThis()
|
|
1916
|
+
* };
|
|
1917
|
+
*
|
|
1918
|
+
* // Chain interceptor methods
|
|
1919
|
+
* mockInterceptor
|
|
1920
|
+
* .intercept('/api/users')
|
|
1921
|
+
* .status(200)
|
|
1922
|
+
* .reply(200, { users: [] });
|
|
1923
|
+
* ```
|
|
1816
1924
|
*/
|
|
1817
1925
|
export interface MockInterceptor {
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1926
|
+
intercept: Vitest.Mock;
|
|
1927
|
+
capture: Vitest.Mock;
|
|
1928
|
+
reply: Vitest.Mock;
|
|
1929
|
+
replyWithError: Vitest.Mock;
|
|
1930
|
+
delay: Vitest.Mock;
|
|
1931
|
+
times: Vitest.Mock;
|
|
1932
|
+
persist: Vitest.Mock;
|
|
1933
|
+
once: Vitest.Mock;
|
|
1934
|
+
reset: Vitest.Mock;
|
|
1935
|
+
isDone: Vitest.Mock;
|
|
1936
|
+
_matches: Array<{
|
|
1937
|
+
method: string;
|
|
1938
|
+
path: string;
|
|
1939
|
+
response?: unknown;
|
|
1940
|
+
error?: Error;
|
|
1941
|
+
delay?: number;
|
|
1942
|
+
times?: number;
|
|
1943
|
+
persistent?: boolean;
|
|
1944
|
+
}>;
|
|
1945
|
+
_captured: Array<{
|
|
1946
|
+
method: string;
|
|
1947
|
+
url: string;
|
|
1948
|
+
headers: Record<string, string>;
|
|
1949
|
+
body?: unknown;
|
|
1950
|
+
timestamp: number;
|
|
1951
|
+
}>;
|
|
1828
1952
|
}
|
|
1829
1953
|
/**
|
|
1830
|
-
*
|
|
1831
|
-
*
|
|
1954
|
+
* Mock OS module interface for testing OS-specific functionality.
|
|
1955
|
+
* Provides mocked versions of Node.js OS module methods.
|
|
1956
|
+
*
|
|
1957
|
+
* @example
|
|
1958
|
+
* ```typescript
|
|
1959
|
+
* const mockOS: MockOS = {
|
|
1960
|
+
* platform: vi.fn(() => 'darwin'),
|
|
1961
|
+
* arch: vi.fn(() => 'x64'),
|
|
1962
|
+
* cpus: vi.fn(() => [{ model: 'Intel', speed: 2400 }]),
|
|
1963
|
+
* totalmem: vi.fn(() => 16000000000),
|
|
1964
|
+
* freemem: vi.fn(() => 8000000000),
|
|
1965
|
+
* hostname: vi.fn(() => 'test-machine'),
|
|
1966
|
+
* homedir: vi.fn(() => '/home/user'),
|
|
1967
|
+
* tmpdir: vi.fn(() => '/tmp')
|
|
1968
|
+
* };
|
|
1969
|
+
* ```
|
|
1832
1970
|
*/
|
|
1833
1971
|
export interface MockOS {
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
homedir: Vitest.
|
|
1848
|
-
|
|
1849
|
-
|
|
1972
|
+
platform: Vitest.Mock<() => string>;
|
|
1973
|
+
arch: Vitest.Mock<() => string>;
|
|
1974
|
+
cpus: Vitest.Mock<() => unknown[]>;
|
|
1975
|
+
totalmem: Vitest.Mock<() => number>;
|
|
1976
|
+
freemem: Vitest.Mock<() => number>;
|
|
1977
|
+
uptime: Vitest.Mock<() => number>;
|
|
1978
|
+
loadavg: Vitest.Mock<() => number[]>;
|
|
1979
|
+
hostname: Vitest.Mock<() => string>;
|
|
1980
|
+
networkInterfaces: Vitest.Mock<() => unknown>;
|
|
1981
|
+
userInfo: Vitest.Mock<() => unknown>;
|
|
1982
|
+
type: Vitest.Mock<() => string>;
|
|
1983
|
+
release: Vitest.Mock<() => string>;
|
|
1984
|
+
version: Vitest.Mock<() => string>;
|
|
1985
|
+
homedir: Vitest.Mock<() => string>;
|
|
1986
|
+
tmpdir: Vitest.Mock<() => string>;
|
|
1987
|
+
endianness: Vitest.Mock<() => string>;
|
|
1988
|
+
EOL: string;
|
|
1850
1989
|
}
|
|
1851
1990
|
/**
|
|
1852
|
-
*
|
|
1853
|
-
*
|
|
1991
|
+
* Mock Cluster module interface for testing clustered Node.js applications.
|
|
1992
|
+
* Provides mocked cluster management functionality.
|
|
1993
|
+
*
|
|
1994
|
+
* @example
|
|
1995
|
+
* ```typescript
|
|
1996
|
+
* const mockCluster: MockCluster = {
|
|
1997
|
+
* isPrimary: true,
|
|
1998
|
+
* isMaster: true,
|
|
1999
|
+
* isWorker: false,
|
|
2000
|
+
* workers: {},
|
|
2001
|
+
* fork: vi.fn().mockReturnValue({ id: 1, process: {} }),
|
|
2002
|
+
* setupPrimary: vi.fn(),
|
|
2003
|
+
* setupMaster: vi.fn(),
|
|
2004
|
+
* disconnect: vi.fn(),
|
|
2005
|
+
* settings: {},
|
|
2006
|
+
* schedulingPolicy: 2,
|
|
2007
|
+
* SCHED_NONE: 1,
|
|
2008
|
+
* SCHED_RR: 2
|
|
2009
|
+
* };
|
|
2010
|
+
* ```
|
|
1854
2011
|
*/
|
|
1855
2012
|
export interface MockCluster {
|
|
1856
|
-
/** Is primary process */
|
|
1857
2013
|
isPrimary: boolean;
|
|
1858
|
-
/** Is master process (deprecated) */
|
|
1859
2014
|
isMaster: boolean;
|
|
1860
|
-
/** Is worker process */
|
|
1861
2015
|
isWorker: boolean;
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
2016
|
+
workers: Record<number, unknown>;
|
|
2017
|
+
fork: Vitest.Mock<(env?: unknown) => unknown>;
|
|
2018
|
+
setupPrimary: Vitest.Mock<(settings?: unknown) => void>;
|
|
2019
|
+
setupMaster: Vitest.Mock<(settings?: unknown) => void>;
|
|
2020
|
+
on: Vitest.Mock;
|
|
2021
|
+
once: Vitest.Mock;
|
|
2022
|
+
removeListener: Vitest.Mock;
|
|
2023
|
+
emit: Vitest.Mock;
|
|
2024
|
+
disconnect: Vitest.Mock<(callback?: Function) => void>;
|
|
2025
|
+
settings: unknown;
|
|
2026
|
+
schedulingPolicy: number;
|
|
2027
|
+
SCHED_NONE: number;
|
|
2028
|
+
SCHED_RR: number;
|
|
1872
2029
|
}
|
|
1873
2030
|
/**
|
|
1874
|
-
*
|
|
1875
|
-
*
|
|
2031
|
+
* Parameters for removing event listeners from event emitters.
|
|
2032
|
+
* Used internally for event listener management.
|
|
2033
|
+
*
|
|
2034
|
+
* @example
|
|
2035
|
+
* ```typescript
|
|
2036
|
+
* const params: RemoveListenerParams = {
|
|
2037
|
+
* events: new Map([['click', new Set([handler1, handler2])]]),
|
|
2038
|
+
* onceEvents: new Map([['load', new Set([onceHandler])]]),
|
|
2039
|
+
* event: 'click',
|
|
2040
|
+
* listener: handler1,
|
|
2041
|
+
* emitter: mockEventEmitter
|
|
2042
|
+
* };
|
|
2043
|
+
* ```
|
|
1876
2044
|
*/
|
|
1877
2045
|
export interface RemoveListenerParams {
|
|
1878
|
-
/** Event listeners map */
|
|
1879
2046
|
events: Map<string | symbol, Set<Function>>;
|
|
1880
|
-
/** Once listeners map */
|
|
1881
2047
|
onceEvents: Map<string | symbol, Set<Function>>;
|
|
1882
|
-
/** Event name */
|
|
1883
2048
|
event: string | symbol;
|
|
1884
|
-
/** Listener function */
|
|
1885
2049
|
listener: Function;
|
|
2050
|
+
emitter: MockEventEmitter;
|
|
1886
2051
|
}
|
|
1887
2052
|
/**
|
|
1888
|
-
*
|
|
1889
|
-
*
|
|
2053
|
+
* Mock file watcher interface for testing file system monitoring.
|
|
2054
|
+
* Simulates file watching behavior for testing file change events.
|
|
2055
|
+
*
|
|
2056
|
+
* @example
|
|
2057
|
+
* ```typescript
|
|
2058
|
+
* const watcher: MockFileWatcher = {
|
|
2059
|
+
* on: vi.fn(),
|
|
2060
|
+
* off: vi.fn(),
|
|
2061
|
+
* emit: vi.fn(),
|
|
2062
|
+
* close: vi.fn(),
|
|
2063
|
+
* simulateChange: (eventType, filename) => {
|
|
2064
|
+
* watcher.emit(eventType, filename);
|
|
2065
|
+
* },
|
|
2066
|
+
* isWatching: () => true,
|
|
2067
|
+
* getListenerCount: (event) => 2,
|
|
2068
|
+
* getAllListeners: () => new Map()
|
|
2069
|
+
* };
|
|
2070
|
+
*
|
|
2071
|
+
* // Simulate file change
|
|
2072
|
+
* watcher.simulateChange('change', 'file.txt');
|
|
2073
|
+
* ```
|
|
1890
2074
|
*/
|
|
1891
2075
|
export interface MockFileWatcher {
|
|
1892
|
-
/** Add event listener */
|
|
1893
2076
|
on: ReturnType<typeof Vitest.vi.fn>;
|
|
1894
|
-
/** Remove event listener */
|
|
1895
2077
|
off: ReturnType<typeof Vitest.vi.fn>;
|
|
1896
|
-
/** Emit event */
|
|
1897
2078
|
emit: ReturnType<typeof Vitest.vi.fn>;
|
|
1898
|
-
/** Close watcher */
|
|
1899
2079
|
close: ReturnType<typeof Vitest.vi.fn>;
|
|
1900
|
-
|
|
1901
|
-
|
|
2080
|
+
simulateChange: (eventType: string, filename?: string) => void;
|
|
2081
|
+
isWatching: () => boolean;
|
|
2082
|
+
getListenerCount: (event: string) => number;
|
|
2083
|
+
getAllListeners: () => Map<string, Set<(...args: unknown[]) => void>>;
|
|
1902
2084
|
}
|
|
1903
2085
|
/**
|
|
1904
|
-
*
|
|
1905
|
-
*
|
|
2086
|
+
* Parameters for configuring console mocking behavior.
|
|
2087
|
+
* Controls how console methods are intercepted and stored.
|
|
2088
|
+
*
|
|
2089
|
+
* @example
|
|
2090
|
+
* ```typescript
|
|
2091
|
+
* const params: ConsoleMockParams = {
|
|
2092
|
+
* type: 'log',
|
|
2093
|
+
* storage: [],
|
|
2094
|
+
* all: [],
|
|
2095
|
+
* originalFn: console.log,
|
|
2096
|
+
* suppressTypes: ['debug'],
|
|
2097
|
+
* formatArguments: (args) => args.join(' '),
|
|
2098
|
+
* captureStackTrace: false
|
|
2099
|
+
* };
|
|
2100
|
+
* ```
|
|
1906
2101
|
*/
|
|
1907
2102
|
export interface ConsoleMockParams {
|
|
1908
|
-
/** Console method type */
|
|
1909
2103
|
type: string;
|
|
1910
|
-
/** Storage array */
|
|
1911
2104
|
storage: string[];
|
|
1912
|
-
/** All calls */
|
|
1913
2105
|
all: Array<{
|
|
1914
2106
|
type: string;
|
|
1915
2107
|
args: unknown[];
|
|
1916
2108
|
}>;
|
|
2109
|
+
originalFn: Function;
|
|
2110
|
+
suppressTypes: string[];
|
|
2111
|
+
formatArguments: (args: unknown[]) => string;
|
|
2112
|
+
captureStackTrace?: boolean;
|
|
1917
2113
|
}
|
|
1918
2114
|
/**
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
2115
|
+
* Mock Buffer implementation for testing buffer operations.
|
|
2116
|
+
* Provides mocked versions of Node.js Buffer static methods.
|
|
2117
|
+
*
|
|
2118
|
+
* @example
|
|
2119
|
+
* ```typescript
|
|
2120
|
+
* const mockBuffer: MockBuffer = {
|
|
2121
|
+
* from: vi.fn().mockImplementation((data) => Buffer.from(data)),
|
|
2122
|
+
* alloc: vi.fn().mockImplementation((size) => Buffer.alloc(size)),
|
|
2123
|
+
* allocUnsafe: vi.fn().mockImplementation((size) => Buffer.allocUnsafe(size)),
|
|
2124
|
+
* concat: vi.fn().mockImplementation((list) => Buffer.concat(list)),
|
|
2125
|
+
* isBuffer: vi.fn().mockReturnValue(true),
|
|
2126
|
+
* byteLength: vi.fn().mockReturnValue(10),
|
|
2127
|
+
* compare: vi.fn().mockReturnValue(0),
|
|
2128
|
+
* isEncoding: vi.fn().mockReturnValue(true)
|
|
2129
|
+
* };
|
|
2130
|
+
* ```
|
|
1921
2131
|
*/
|
|
1922
2132
|
export interface MockBuffer {
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
/** Compare buffers */
|
|
1932
|
-
compare: Vitest.MockInstance;
|
|
2133
|
+
from: Vitest.Mock;
|
|
2134
|
+
alloc: Vitest.Mock;
|
|
2135
|
+
allocUnsafe: Vitest.Mock;
|
|
2136
|
+
concat: Vitest.Mock;
|
|
2137
|
+
isBuffer: Vitest.Mock;
|
|
2138
|
+
byteLength: Vitest.Mock;
|
|
2139
|
+
compare: Vitest.Mock;
|
|
2140
|
+
isEncoding: Vitest.Mock;
|
|
1933
2141
|
}
|
|
1934
2142
|
/**
|
|
1935
|
-
*
|
|
1936
|
-
*
|
|
2143
|
+
* Mock Worker Threads interface for testing multi-threaded Node.js applications.
|
|
2144
|
+
* Provides mocked worker thread functionality.
|
|
2145
|
+
*
|
|
2146
|
+
* @example
|
|
2147
|
+
* ```typescript
|
|
2148
|
+
* const mockWorkerThreads: MockWorkerThreads = {
|
|
2149
|
+
* Worker: vi.fn().mockImplementation(() => ({
|
|
2150
|
+
* postMessage: vi.fn(),
|
|
2151
|
+
* terminate: vi.fn()
|
|
2152
|
+
* })),
|
|
2153
|
+
* isMainThread: true,
|
|
2154
|
+
* parentPort: null,
|
|
2155
|
+
* workerData: { task: 'process' },
|
|
2156
|
+
* threadId: 0,
|
|
2157
|
+
* resourceLimits: {},
|
|
2158
|
+
* getEnvironmentData: vi.fn(),
|
|
2159
|
+
* setEnvironmentData: vi.fn(),
|
|
2160
|
+
* SHARE_ENV: Symbol('SHARE_ENV'),
|
|
2161
|
+
* markAsUntransferable: vi.fn(),
|
|
2162
|
+
* moveMessagePortToContext: vi.fn(),
|
|
2163
|
+
* receiveMessageOnPort: vi.fn()
|
|
2164
|
+
* };
|
|
2165
|
+
* ```
|
|
1937
2166
|
*/
|
|
1938
2167
|
export interface MockWorkerThreads {
|
|
1939
|
-
|
|
1940
|
-
Worker: Vitest.MockInstance;
|
|
1941
|
-
/** Is main thread */
|
|
2168
|
+
Worker: Vitest.Mock;
|
|
1942
2169
|
isMainThread: boolean;
|
|
1943
|
-
/** Parent port */
|
|
1944
2170
|
parentPort: unknown;
|
|
1945
|
-
/** Worker data */
|
|
1946
2171
|
workerData: unknown;
|
|
1947
|
-
/** Thread ID */
|
|
1948
2172
|
threadId: number;
|
|
2173
|
+
resourceLimits: Record<string, unknown>;
|
|
2174
|
+
getEnvironmentData: Vitest.Mock<() => unknown>;
|
|
2175
|
+
setEnvironmentData: Vitest.Mock<(key: string, value: unknown) => void>;
|
|
2176
|
+
SHARE_ENV: symbol;
|
|
2177
|
+
markAsUntransferable: Vitest.Mock<(obj: unknown) => void>;
|
|
2178
|
+
moveMessagePortToContext: Vitest.Mock<(port: unknown, context: unknown) => unknown>;
|
|
2179
|
+
receiveMessageOnPort: Vitest.Mock<(port: unknown) => unknown>;
|
|
1949
2180
|
}
|