@plyaz/types 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/types.d.ts +20 -53
- package/dist/auth/types.d.ts +3 -20
- package/dist/common/types.d.ts +1565 -3
- package/dist/errors/types.d.ts +4 -39
- package/dist/events/payload.d.ts +2 -3
- package/dist/events/types.d.ts +17 -78
- package/dist/features/cache/types.d.ts +7 -23
- package/dist/features/community/blog/providers/wordpress/types.d.ts +2 -3
- package/dist/features/community/blog/types.d.ts +6 -8
- package/dist/features/feature-flag/types.d.ts +37 -156
- package/dist/index.js.map +1 -1
- package/dist/testing/common/assertions/types.d.ts +15 -38
- package/dist/testing/common/factories/types.d.ts +30 -138
- package/dist/testing/common/mocks/types.d.ts +23 -66
- package/dist/testing/common/patterns/types.d.ts +13 -26
- package/dist/testing/common/utils/types.d.ts +180 -291
- package/dist/testing/common/wrappers/types.d.ts +14 -29
- package/dist/testing/features/cache/types.d.ts +3 -7
- package/dist/testing/features/feature-flags/types.d.ts +20 -31
- package/dist/web3/types.d.ts +3 -12
- package/package.json +2 -1
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Type definitions for factory utilities.
|
|
5
5
|
*/
|
|
6
|
+
import type { Promisable, UnknownRecord, UnknownArray, SetOptional } from 'type-fest';
|
|
6
7
|
import type * as Vitest from 'vitest';
|
|
8
|
+
import type { Entity, Named, WithMetadata, Timestamped, SoftDeletable, Describable, Authored, WithTags, Versioned, WithSource, WithLabels, WithAnnotations, Tracked, WithDuration, WithExpiration, WithLastAccessed, NavigablePaginatedCollection, WithTimestamp, WithEmail, WithRoles, WithPermissions, WithUserId, WithLocale, WithTimezone, WithUserAgent, WithIpAddress, WithCountry, WithEnvironment, WithHttpStatus, WithRequestId, WithHeaders, WithErrorDetailed } from '../../../common/types';
|
|
7
9
|
/**
|
|
8
10
|
* Test user interface for user-related testing
|
|
9
11
|
*
|
|
@@ -21,23 +23,7 @@ import type * as Vitest from 'vitest';
|
|
|
21
23
|
* };
|
|
22
24
|
* ```
|
|
23
25
|
*/
|
|
24
|
-
export interface TestUser {
|
|
25
|
-
/** Unique user identifier */
|
|
26
|
-
id: string;
|
|
27
|
-
/** User email address */
|
|
28
|
-
email: string;
|
|
29
|
-
/** User display name */
|
|
30
|
-
name: string;
|
|
31
|
-
/** User roles */
|
|
32
|
-
roles: string[];
|
|
33
|
-
/** User permissions */
|
|
34
|
-
permissions: string[];
|
|
35
|
-
/** Additional user metadata */
|
|
36
|
-
metadata?: Record<string, unknown>;
|
|
37
|
-
/** User creation timestamp */
|
|
38
|
-
createdAt: Date;
|
|
39
|
-
/** User last update timestamp */
|
|
40
|
-
updatedAt: Date;
|
|
26
|
+
export interface TestUser extends Entity, Named, WithMetadata, WithEmail, WithRoles, WithPermissions {
|
|
41
27
|
}
|
|
42
28
|
/**
|
|
43
29
|
* Test context interface for environment and user context
|
|
@@ -56,28 +42,14 @@ export interface TestUser {
|
|
|
56
42
|
* };
|
|
57
43
|
* ```
|
|
58
44
|
*/
|
|
59
|
-
export
|
|
60
|
-
/** Current user ID */
|
|
61
|
-
userId?: string;
|
|
62
|
-
/** Runtime environment */
|
|
63
|
-
environment: string;
|
|
64
|
-
/** User locale */
|
|
65
|
-
locale?: string;
|
|
66
|
-
/** User timezone */
|
|
67
|
-
timezone?: string;
|
|
68
|
-
/** User agent string */
|
|
69
|
-
userAgent?: string;
|
|
70
|
-
/** Client IP address */
|
|
71
|
-
ip?: string;
|
|
72
|
-
/** Client country */
|
|
73
|
-
country?: string;
|
|
45
|
+
export type TestContext = SetOptional<WithUserId & WithEnvironment & WithLocale & WithTimezone & WithUserAgent & WithIpAddress & WithCountry, 'userId' | 'locale' | 'timezone' | 'userAgent' | 'ip' | 'country'> & {
|
|
74
46
|
/** Client region */
|
|
75
47
|
region?: string;
|
|
76
48
|
/** Client city */
|
|
77
49
|
city?: string;
|
|
78
50
|
/** Additional context fields */
|
|
79
51
|
[key: string]: string | undefined;
|
|
80
|
-
}
|
|
52
|
+
};
|
|
81
53
|
/**
|
|
82
54
|
* Test API response interface for HTTP response testing
|
|
83
55
|
*
|
|
@@ -95,19 +67,9 @@ export interface TestContext {
|
|
|
95
67
|
* };
|
|
96
68
|
* ```
|
|
97
69
|
*/
|
|
98
|
-
export interface TestApiResponse<T = unknown> {
|
|
70
|
+
export interface TestApiResponse<T = unknown> extends WithTimestamp<Date>, WithHeaders, WithRequestId, WithHttpStatus {
|
|
99
71
|
/** Response data payload */
|
|
100
72
|
data: T;
|
|
101
|
-
/** HTTP status code */
|
|
102
|
-
status: number;
|
|
103
|
-
/** HTTP status text */
|
|
104
|
-
statusText: string;
|
|
105
|
-
/** Response headers */
|
|
106
|
-
headers: Record<string, string>;
|
|
107
|
-
/** Response timestamp */
|
|
108
|
-
timestamp: Date;
|
|
109
|
-
/** Unique request identifier */
|
|
110
|
-
requestId: string;
|
|
111
73
|
}
|
|
112
74
|
/**
|
|
113
75
|
* Test error response interface for error handling testing
|
|
@@ -124,20 +86,7 @@ export interface TestApiResponse<T = unknown> {
|
|
|
124
86
|
* };
|
|
125
87
|
* ```
|
|
126
88
|
*/
|
|
127
|
-
export
|
|
128
|
-
/** Error type/name */
|
|
129
|
-
error: string;
|
|
130
|
-
/** Human-readable error message */
|
|
131
|
-
message: string;
|
|
132
|
-
/** HTTP status code */
|
|
133
|
-
statusCode: number;
|
|
134
|
-
/** Error timestamp */
|
|
135
|
-
timestamp: Date;
|
|
136
|
-
/** Request path where error occurred */
|
|
137
|
-
path?: string;
|
|
138
|
-
/** Additional error details */
|
|
139
|
-
details?: unknown;
|
|
140
|
-
}
|
|
89
|
+
export type TestErrorResponse = WithErrorDetailed;
|
|
141
90
|
/**
|
|
142
91
|
* Test pagination data interface for paginated response testing
|
|
143
92
|
*
|
|
@@ -156,22 +105,7 @@ export interface TestErrorResponse {
|
|
|
156
105
|
* };
|
|
157
106
|
* ```
|
|
158
107
|
*/
|
|
159
|
-
export
|
|
160
|
-
/** Items in current page */
|
|
161
|
-
items: T[];
|
|
162
|
-
/** Total number of items */
|
|
163
|
-
total: number;
|
|
164
|
-
/** Current page number */
|
|
165
|
-
page: number;
|
|
166
|
-
/** Number of items per page */
|
|
167
|
-
pageSize: number;
|
|
168
|
-
/** Total number of pages */
|
|
169
|
-
totalPages: number;
|
|
170
|
-
/** Whether there's a next page */
|
|
171
|
-
hasNext: boolean;
|
|
172
|
-
/** Whether there's a previous page */
|
|
173
|
-
hasPrevious: boolean;
|
|
174
|
-
}
|
|
108
|
+
export type TestPaginationData<T> = NavigablePaginatedCollection<T>;
|
|
175
109
|
/**
|
|
176
110
|
* Test metadata interface for entity metadata testing
|
|
177
111
|
*
|
|
@@ -188,22 +122,7 @@ export interface TestPaginationData<T> {
|
|
|
188
122
|
* };
|
|
189
123
|
* ```
|
|
190
124
|
*/
|
|
191
|
-
export
|
|
192
|
-
/** Version string */
|
|
193
|
-
version: string;
|
|
194
|
-
/** Data source identifier */
|
|
195
|
-
source: string;
|
|
196
|
-
/** Creator identifier */
|
|
197
|
-
createdBy: string;
|
|
198
|
-
/** Last updater identifier */
|
|
199
|
-
updatedBy: string;
|
|
200
|
-
/** Metadata tags */
|
|
201
|
-
tags: string[];
|
|
202
|
-
/** Key-value labels */
|
|
203
|
-
labels: Record<string, string>;
|
|
204
|
-
/** Additional annotations */
|
|
205
|
-
annotations: Record<string, unknown>;
|
|
206
|
-
}
|
|
125
|
+
export type TestMetadata = Versioned & WithSource & Authored & WithTags & WithLabels & WithAnnotations;
|
|
207
126
|
/**
|
|
208
127
|
* Test timestamps interface for entity lifecycle testing
|
|
209
128
|
*
|
|
@@ -218,17 +137,7 @@ export interface TestMetadata {
|
|
|
218
137
|
* };
|
|
219
138
|
* ```
|
|
220
139
|
*/
|
|
221
|
-
export interface TestTimestamps {
|
|
222
|
-
/** Entity creation date */
|
|
223
|
-
createdAt: Date;
|
|
224
|
-
/** Entity last update date */
|
|
225
|
-
updatedAt: Date;
|
|
226
|
-
/** Entity deletion date (soft delete) */
|
|
227
|
-
deletedAt?: Date | null;
|
|
228
|
-
/** Entity expiration date */
|
|
229
|
-
expiresAt?: Date | null;
|
|
230
|
-
/** Entity last access date */
|
|
231
|
-
lastAccessedAt?: Date | null;
|
|
140
|
+
export interface TestTimestamps extends Timestamped<Date, Date>, SoftDeletable, WithExpiration, WithLastAccessed {
|
|
232
141
|
}
|
|
233
142
|
/**
|
|
234
143
|
* Test scenario interface for scenario-driven testing
|
|
@@ -252,25 +161,21 @@ export interface TestTimestamps {
|
|
|
252
161
|
* };
|
|
253
162
|
* ```
|
|
254
163
|
*/
|
|
255
|
-
export interface TestScenario<TContext, TInput, TExpected> {
|
|
256
|
-
/** Test scenario name */
|
|
257
|
-
name: string;
|
|
258
|
-
/** Test scenario description */
|
|
259
|
-
description: string;
|
|
164
|
+
export interface TestScenario<TContext, TInput, TExpected> extends Named, Describable {
|
|
260
165
|
/** Test data or factory function */
|
|
261
166
|
data: TContext | (() => TContext);
|
|
262
167
|
/** Setup function executed before test */
|
|
263
|
-
setup?: (context?: TContext) =>
|
|
168
|
+
setup?: (context?: TContext) => Promisable<void>;
|
|
264
169
|
/** Teardown function executed after test */
|
|
265
|
-
teardown?: (context?: TContext) =>
|
|
170
|
+
teardown?: (context?: TContext) => Promisable<void>;
|
|
266
171
|
/** Arrange phase - prepare test context */
|
|
267
172
|
arrange: () => TContext | Promise<TContext>;
|
|
268
173
|
/** Act phase - execute the action being tested */
|
|
269
174
|
act: (instance: TContext) => unknown | Promise<unknown>;
|
|
270
175
|
/** Assert phase - verify the results */
|
|
271
|
-
assert: (result: unknown, instance: TContext) =>
|
|
176
|
+
assert: (result: unknown, instance: TContext) => Promisable<void>;
|
|
272
177
|
/** Cleanup function executed after assertions */
|
|
273
|
-
cleanup?: (context?: Awaited<TContext>) =>
|
|
178
|
+
cleanup?: (context?: Awaited<TContext>) => Promisable<void>;
|
|
274
179
|
/** Optional test context */
|
|
275
180
|
context?: TContext;
|
|
276
181
|
/** Test input data */
|
|
@@ -310,17 +215,17 @@ export interface ScenarioTestSuite<TContext, TInput, TExpected> {
|
|
|
310
215
|
/** Test suite name */
|
|
311
216
|
suiteName: string;
|
|
312
217
|
/** Setup function executed before all scenarios */
|
|
313
|
-
beforeAll?: () =>
|
|
218
|
+
beforeAll?: () => Promisable<void>;
|
|
314
219
|
/** Cleanup function executed after all scenarios */
|
|
315
|
-
afterAll?: () =>
|
|
220
|
+
afterAll?: () => Promisable<void>;
|
|
316
221
|
/** Setup function executed before each scenario */
|
|
317
|
-
beforeEach?: (scenario: TestScenario<TContext, TInput, TExpected>) =>
|
|
222
|
+
beforeEach?: (scenario: TestScenario<TContext, TInput, TExpected>) => Promisable<void>;
|
|
318
223
|
/** Cleanup function executed after each scenario */
|
|
319
|
-
afterEach?: (scenario: TestScenario<TContext, TInput, TExpected>) =>
|
|
224
|
+
afterEach?: (scenario: TestScenario<TContext, TInput, TExpected>) => Promisable<void>;
|
|
320
225
|
/** Array of test scenarios */
|
|
321
226
|
scenarios: TestScenario<TContext, TInput, TExpected>[];
|
|
322
227
|
/** Function to execute for each scenario */
|
|
323
|
-
testFn: (input: TInput, context?: TContext) =>
|
|
228
|
+
testFn: (input: TInput, context?: TContext) => Promisable<TExpected>;
|
|
324
229
|
/** Custom assertion function */
|
|
325
230
|
assertFn?: (actual: TExpected, expected: TExpected, scenario: TestScenario<TContext, TInput, TExpected>) => void;
|
|
326
231
|
}
|
|
@@ -468,9 +373,9 @@ export interface UpdateResult {
|
|
|
468
373
|
/** Number of affected rows */
|
|
469
374
|
affected: number;
|
|
470
375
|
/** Raw database response */
|
|
471
|
-
raw:
|
|
376
|
+
raw: UnknownRecord;
|
|
472
377
|
/** Generated entity maps */
|
|
473
|
-
generatedMaps:
|
|
378
|
+
generatedMaps: UnknownArray;
|
|
474
379
|
}
|
|
475
380
|
/**
|
|
476
381
|
* Database delete operation result
|
|
@@ -489,7 +394,7 @@ export interface DeleteResult {
|
|
|
489
394
|
/** Number of affected rows */
|
|
490
395
|
affected: number;
|
|
491
396
|
/** Raw database response */
|
|
492
|
-
raw:
|
|
397
|
+
raw: UnknownRecord;
|
|
493
398
|
}
|
|
494
399
|
/**
|
|
495
400
|
* HTTP HEAD response interface
|
|
@@ -504,10 +409,7 @@ export interface DeleteResult {
|
|
|
504
409
|
* };
|
|
505
410
|
* ```
|
|
506
411
|
*/
|
|
507
|
-
export
|
|
508
|
-
/** Response headers */
|
|
509
|
-
headers: Record<string, unknown>;
|
|
510
|
-
}
|
|
412
|
+
export type HeadResponse = WithHeaders;
|
|
511
413
|
/**
|
|
512
414
|
* Generic data response interface
|
|
513
415
|
*
|
|
@@ -523,7 +425,7 @@ export interface HeadResponse {
|
|
|
523
425
|
*/
|
|
524
426
|
export interface DataResponse {
|
|
525
427
|
/** Response data */
|
|
526
|
-
data:
|
|
428
|
+
data: UnknownRecord;
|
|
527
429
|
}
|
|
528
430
|
/**
|
|
529
431
|
* Mock definition interface for configuring mock objects
|
|
@@ -618,7 +520,7 @@ export interface MockCallExpectation<T> {
|
|
|
618
520
|
/** Method name to expect */
|
|
619
521
|
method: keyof T;
|
|
620
522
|
/** Expected arguments */
|
|
621
|
-
args?:
|
|
523
|
+
args?: UnknownArray;
|
|
622
524
|
/** Expected number of calls */
|
|
623
525
|
times?: number;
|
|
624
526
|
/** Expected return value */
|
|
@@ -649,15 +551,13 @@ export interface MockCallExpectation<T> {
|
|
|
649
551
|
* };
|
|
650
552
|
* ```
|
|
651
553
|
*/
|
|
652
|
-
export interface ScenarioGroup<TContext, TInput, TExpected> {
|
|
653
|
-
/** Group name */
|
|
654
|
-
name: string;
|
|
554
|
+
export interface ScenarioGroup<TContext, TInput, TExpected> extends Named {
|
|
655
555
|
/** Scenarios in this group */
|
|
656
556
|
scenarios: TestScenario<TContext, TInput, TExpected>[];
|
|
657
557
|
/** Common setup for all scenarios */
|
|
658
|
-
commonSetup?: (context?: TContext) =>
|
|
558
|
+
commonSetup?: (context?: TContext) => Promisable<void>;
|
|
659
559
|
/** Common teardown for all scenarios */
|
|
660
|
-
commonTeardown?: (context?: TContext) =>
|
|
560
|
+
commonTeardown?: (context?: TContext) => Promisable<void>;
|
|
661
561
|
}
|
|
662
562
|
/**
|
|
663
563
|
* Scenario result tracker for complex assertions and reporting
|
|
@@ -724,17 +624,9 @@ export interface ScenarioResult<T> {
|
|
|
724
624
|
* };
|
|
725
625
|
* ```
|
|
726
626
|
*/
|
|
727
|
-
export interface TrackedCallRecord<TArgs extends unknown[], TReturn> {
|
|
627
|
+
export interface TrackedCallRecord<TArgs extends unknown[], TReturn> extends Tracked<TReturn>, WithDuration {
|
|
728
628
|
/** Function arguments */
|
|
729
629
|
args: TArgs;
|
|
730
|
-
/** Call timestamp */
|
|
731
|
-
timestamp: Date;
|
|
732
|
-
/** Return value */
|
|
733
|
-
result?: TReturn;
|
|
734
|
-
/** Error if thrown */
|
|
735
|
-
error?: Error;
|
|
736
|
-
/** Call duration in milliseconds */
|
|
737
|
-
duration?: number;
|
|
738
630
|
}
|
|
739
631
|
/**
|
|
740
632
|
* Enhanced mock function with call tracking and filtering capabilities.
|
|
@@ -42,6 +42,8 @@ import type * as Next from 'next';
|
|
|
42
42
|
import type * as NextRouter from 'next/router';
|
|
43
43
|
import type * as NextImage from 'next/image';
|
|
44
44
|
import type * as NextLink from 'next/link';
|
|
45
|
+
import type { UnknownRecord, UnknownArray, Arrayable } from 'type-fest';
|
|
46
|
+
import type { Named, WithStatusCode, WithStatusMessage, WithUrl, WithHttpMethod, WithHeaders, WithQueryParams, WithBody, WithCookies, WithParams, Resettable, WithStatus, Identifiable } from '../../../common/types';
|
|
45
47
|
/**
|
|
46
48
|
* Mock file system interface matching Node.js fs module
|
|
47
49
|
*
|
|
@@ -442,9 +444,7 @@ export interface MockTestingModule {
|
|
|
442
444
|
* };
|
|
443
445
|
* ```
|
|
444
446
|
*/
|
|
445
|
-
export type HttpExceptionError = Error & {
|
|
446
|
-
/** HTTP status code */
|
|
447
|
-
status: number;
|
|
447
|
+
export type HttpExceptionError = Error & WithStatus & {
|
|
448
448
|
/** Error response data */
|
|
449
449
|
response: string | object;
|
|
450
450
|
/** Get HTTP status code */
|
|
@@ -465,9 +465,7 @@ export type HttpExceptionError = Error & {
|
|
|
465
465
|
* };
|
|
466
466
|
* ```
|
|
467
467
|
*/
|
|
468
|
-
export type SimpleExceptionError = Error & {
|
|
469
|
-
/** Error status code */
|
|
470
|
-
status: number;
|
|
468
|
+
export type SimpleExceptionError = Error & WithStatus & {
|
|
471
469
|
/** Error response data */
|
|
472
470
|
response: unknown;
|
|
473
471
|
};
|
|
@@ -544,7 +542,7 @@ export interface MockProvider<T = unknown> {
|
|
|
544
542
|
* expect(router.push).toHaveBeenCalledWith('/users/456');
|
|
545
543
|
* ```
|
|
546
544
|
*/
|
|
547
|
-
export interface MockRouter {
|
|
545
|
+
export interface MockRouter extends WithQueryParams {
|
|
548
546
|
/** Navigate to new route */
|
|
549
547
|
push: Vitest.Mock;
|
|
550
548
|
/** Replace current route */
|
|
@@ -559,8 +557,6 @@ export interface MockRouter {
|
|
|
559
557
|
prefetch: Vitest.Mock;
|
|
560
558
|
/** Current pathname */
|
|
561
559
|
pathname: string;
|
|
562
|
-
/** Query parameters */
|
|
563
|
-
query: Record<string, string | string[]>;
|
|
564
560
|
/** Full path with query */
|
|
565
561
|
asPath: string;
|
|
566
562
|
/** Navigate by delta in history */
|
|
@@ -783,7 +779,6 @@ export interface MockNextRouter extends Omit<NextRouter.NextRouter, 'push' | 're
|
|
|
783
779
|
};
|
|
784
780
|
pathname: string;
|
|
785
781
|
route: string;
|
|
786
|
-
query: Record<string, string | string[]>;
|
|
787
782
|
asPath: string;
|
|
788
783
|
basePath: string;
|
|
789
784
|
locale?: string;
|
|
@@ -825,15 +820,7 @@ export type MockNextLink = NextLink.LinkProps & {
|
|
|
825
820
|
* };
|
|
826
821
|
* ```
|
|
827
822
|
*/
|
|
828
|
-
export type MockNextApiRequest = Partial<Next.NextApiRequest> & {
|
|
829
|
-
/** Request headers */
|
|
830
|
-
headers: Record<string, string | string[]>;
|
|
831
|
-
/** Query parameters */
|
|
832
|
-
query: Record<string, string | string[]>;
|
|
833
|
-
/** Request body */
|
|
834
|
-
body: unknown;
|
|
835
|
-
/** Request cookies */
|
|
836
|
-
cookies: Record<string, string>;
|
|
823
|
+
export type MockNextApiRequest = Partial<Next.NextApiRequest> & WithHeaders & WithQueryParams & WithBody & WithCookies & {
|
|
837
824
|
/** Environment variables */
|
|
838
825
|
env: Record<string, string | undefined>;
|
|
839
826
|
};
|
|
@@ -853,7 +840,7 @@ export type MockNextApiRequest = Partial<Next.NextApiRequest> & {
|
|
|
853
840
|
* expect(res.statusCode).toBe(200);
|
|
854
841
|
* ```
|
|
855
842
|
*/
|
|
856
|
-
export interface MockNextApiResponse {
|
|
843
|
+
export interface MockNextApiResponse extends WithStatusMessage, WithStatusCode {
|
|
857
844
|
/** Set response status */
|
|
858
845
|
status: Vitest.Mock;
|
|
859
846
|
/** Send JSON response */
|
|
@@ -872,10 +859,6 @@ export interface MockNextApiResponse {
|
|
|
872
859
|
write: Vitest.Mock;
|
|
873
860
|
/** End response */
|
|
874
861
|
end: Vitest.Mock;
|
|
875
|
-
/** Current status code */
|
|
876
|
-
statusCode: number;
|
|
877
|
-
/** Current status message */
|
|
878
|
-
statusMessage: string;
|
|
879
862
|
}
|
|
880
863
|
/**
|
|
881
864
|
* Mock Next.js Next.GetServerSidePropsContext with mock request/response
|
|
@@ -1015,21 +998,7 @@ export interface HttpMockOptions {
|
|
|
1015
998
|
* };
|
|
1016
999
|
* ```
|
|
1017
1000
|
*/
|
|
1018
|
-
export interface MockHttpRequest {
|
|
1019
|
-
/** HTTP method */
|
|
1020
|
-
method: string;
|
|
1021
|
-
/** Request URL */
|
|
1022
|
-
url: string;
|
|
1023
|
-
/** Request headers */
|
|
1024
|
-
headers: Record<string, string | string[]>;
|
|
1025
|
-
/** Query parameters */
|
|
1026
|
-
query: Record<string, string | string[]>;
|
|
1027
|
-
/** Route parameters */
|
|
1028
|
-
params: Record<string, string>;
|
|
1029
|
-
/** Request body */
|
|
1030
|
-
body: unknown;
|
|
1031
|
-
/** Request cookies */
|
|
1032
|
-
cookies?: Record<string, string>;
|
|
1001
|
+
export interface MockHttpRequest extends WithUrl, WithHttpMethod, WithHeaders, WithQueryParams, WithBody, WithParams, Partial<WithCookies> {
|
|
1033
1002
|
/** Environment variables */
|
|
1034
1003
|
env?: Record<string, string | undefined>;
|
|
1035
1004
|
/** Socket information */
|
|
@@ -1070,11 +1039,7 @@ export interface MockHttpRequest {
|
|
|
1070
1039
|
* expect(response.statusCode).toBe(200);
|
|
1071
1040
|
* ```
|
|
1072
1041
|
*/
|
|
1073
|
-
export interface MockHttpResponse {
|
|
1074
|
-
/** Current status code */
|
|
1075
|
-
statusCode: number;
|
|
1076
|
-
/** Current status message */
|
|
1077
|
-
statusMessage: string;
|
|
1042
|
+
export interface MockHttpResponse extends WithStatusCode, WithStatusMessage, WithHeaders {
|
|
1078
1043
|
/** Set status code */
|
|
1079
1044
|
status: Vitest.Mock;
|
|
1080
1045
|
/** Send JSON response */
|
|
@@ -1105,8 +1070,6 @@ export interface MockHttpResponse {
|
|
|
1105
1070
|
finished?: boolean;
|
|
1106
1071
|
/** Whether headers are sent */
|
|
1107
1072
|
headersSent?: boolean;
|
|
1108
|
-
/** Response headers */
|
|
1109
|
-
headers?: Record<string, string | string[]>;
|
|
1110
1073
|
}
|
|
1111
1074
|
/**
|
|
1112
1075
|
* Browser history entry interface
|
|
@@ -1224,15 +1187,13 @@ export interface NextLinkChildProps {
|
|
|
1224
1187
|
* };
|
|
1225
1188
|
* ```
|
|
1226
1189
|
*/
|
|
1227
|
-
export interface ErrorHandlerMock {
|
|
1190
|
+
export interface ErrorHandlerMock extends Resettable {
|
|
1228
1191
|
/** Error event handler */
|
|
1229
1192
|
onError: Vitest.Mock;
|
|
1230
1193
|
/** Catch block handler */
|
|
1231
1194
|
onCatch: Vitest.Mock;
|
|
1232
1195
|
/** Finally block handler */
|
|
1233
1196
|
onFinally: Vitest.Mock;
|
|
1234
|
-
/** Reset all handlers */
|
|
1235
|
-
reset: () => void;
|
|
1236
1197
|
}
|
|
1237
1198
|
/**
|
|
1238
1199
|
* Generic value wrapper interface
|
|
@@ -1272,9 +1233,7 @@ export interface ValueWrapper<T> {
|
|
|
1272
1233
|
* };
|
|
1273
1234
|
* ```
|
|
1274
1235
|
*/
|
|
1275
|
-
export interface HttpTestScenario {
|
|
1276
|
-
/** Descriptive name for the test scenario */
|
|
1277
|
-
name: string;
|
|
1236
|
+
export interface HttpTestScenario extends Named {
|
|
1278
1237
|
/** Target framework for the test */
|
|
1279
1238
|
framework?: 'node' | 'express' | 'nextjs';
|
|
1280
1239
|
/** Mock request configuration */
|
|
@@ -1284,7 +1243,7 @@ export interface HttpTestScenario {
|
|
|
1284
1243
|
/** Expected response body */
|
|
1285
1244
|
expectedBody?: unknown;
|
|
1286
1245
|
/** Expected response headers */
|
|
1287
|
-
expectedHeaders?: Record<string, string
|
|
1246
|
+
expectedHeaders?: Record<string, Arrayable<string>>;
|
|
1288
1247
|
/** Expected redirect URL */
|
|
1289
1248
|
expectedRedirect?: string;
|
|
1290
1249
|
}
|
|
@@ -1303,7 +1262,7 @@ export interface TimerCallbackEntry {
|
|
|
1303
1262
|
/** Function to be called */
|
|
1304
1263
|
callback: Function;
|
|
1305
1264
|
/** Arguments to pass to callback */
|
|
1306
|
-
args:
|
|
1265
|
+
args: UnknownArray;
|
|
1307
1266
|
}
|
|
1308
1267
|
/**
|
|
1309
1268
|
* Mock HTTP server interface for testing server operations
|
|
@@ -1536,7 +1495,7 @@ export interface StatefulMock<TState, TMethods> {
|
|
|
1536
1495
|
/** History of method calls with arguments and timestamps */
|
|
1537
1496
|
history: Array<{
|
|
1538
1497
|
method: string;
|
|
1539
|
-
args:
|
|
1498
|
+
args: UnknownArray;
|
|
1540
1499
|
timestamp: number;
|
|
1541
1500
|
}>;
|
|
1542
1501
|
/** Clear the call history */
|
|
@@ -1575,8 +1534,7 @@ export type CreateMockUseRouterReturn = Vitest.Mock;
|
|
|
1575
1534
|
/**
|
|
1576
1535
|
* Type definition for createMockWebSocket function return
|
|
1577
1536
|
*/
|
|
1578
|
-
export interface CreateMockWebSocketReturn {
|
|
1579
|
-
url: string;
|
|
1537
|
+
export interface CreateMockWebSocketReturn extends WithUrl {
|
|
1580
1538
|
protocol: string;
|
|
1581
1539
|
extensions: string;
|
|
1582
1540
|
readyState: number;
|
|
@@ -1587,7 +1545,7 @@ export interface CreateMockWebSocketReturn {
|
|
|
1587
1545
|
ping: Vitest.Mock;
|
|
1588
1546
|
pong: Vitest.Mock;
|
|
1589
1547
|
terminate: Vitest.Mock;
|
|
1590
|
-
messages:
|
|
1548
|
+
messages: UnknownArray;
|
|
1591
1549
|
simulateMessage: (data: unknown) => void;
|
|
1592
1550
|
simulateError: (error: Error) => void;
|
|
1593
1551
|
simulateClose: (code?: number, reason?: string) => void;
|
|
@@ -1678,7 +1636,7 @@ export interface AdvancedConsoleMock {
|
|
|
1678
1636
|
debugs: string[];
|
|
1679
1637
|
all: Array<{
|
|
1680
1638
|
type: string;
|
|
1681
|
-
args:
|
|
1639
|
+
args: UnknownArray;
|
|
1682
1640
|
}>;
|
|
1683
1641
|
install: () => void;
|
|
1684
1642
|
uninstall: () => void;
|
|
@@ -1885,7 +1843,7 @@ export interface MockCookie {
|
|
|
1885
1843
|
* await mockSession.save();
|
|
1886
1844
|
* ```
|
|
1887
1845
|
*/
|
|
1888
|
-
export interface MockSession {
|
|
1846
|
+
export interface MockSession extends Identifiable {
|
|
1889
1847
|
get: Vitest.Mock;
|
|
1890
1848
|
set: Vitest.Mock;
|
|
1891
1849
|
delete: Vitest.Mock;
|
|
@@ -1896,8 +1854,7 @@ export interface MockSession {
|
|
|
1896
1854
|
regenerate: Vitest.Mock;
|
|
1897
1855
|
touch: Vitest.Mock;
|
|
1898
1856
|
reload: Vitest.Mock;
|
|
1899
|
-
|
|
1900
|
-
_data: Record<string, unknown>;
|
|
1857
|
+
_data: UnknownRecord;
|
|
1901
1858
|
_dirty: boolean;
|
|
1902
1859
|
_destroyed: boolean;
|
|
1903
1860
|
}
|
|
@@ -1971,7 +1928,7 @@ export interface MockInterceptor {
|
|
|
1971
1928
|
export interface MockOS {
|
|
1972
1929
|
platform: Vitest.Mock<() => string>;
|
|
1973
1930
|
arch: Vitest.Mock<() => string>;
|
|
1974
|
-
cpus: Vitest.Mock<() =>
|
|
1931
|
+
cpus: Vitest.Mock<() => UnknownArray>;
|
|
1975
1932
|
totalmem: Vitest.Mock<() => number>;
|
|
1976
1933
|
freemem: Vitest.Mock<() => number>;
|
|
1977
1934
|
uptime: Vitest.Mock<() => number>;
|
|
@@ -2104,11 +2061,11 @@ export interface ConsoleMockParams {
|
|
|
2104
2061
|
storage: string[];
|
|
2105
2062
|
all: Array<{
|
|
2106
2063
|
type: string;
|
|
2107
|
-
args:
|
|
2064
|
+
args: UnknownArray;
|
|
2108
2065
|
}>;
|
|
2109
2066
|
originalFn: Function;
|
|
2110
2067
|
suppressTypes: string[];
|
|
2111
|
-
formatArguments: (args:
|
|
2068
|
+
formatArguments: (args: UnknownArray) => string;
|
|
2112
2069
|
captureStackTrace?: boolean;
|
|
2113
2070
|
}
|
|
2114
2071
|
/**
|
|
@@ -2170,7 +2127,7 @@ export interface MockWorkerThreads {
|
|
|
2170
2127
|
parentPort: unknown;
|
|
2171
2128
|
workerData: unknown;
|
|
2172
2129
|
threadId: number;
|
|
2173
|
-
resourceLimits:
|
|
2130
|
+
resourceLimits: UnknownRecord;
|
|
2174
2131
|
getEnvironmentData: Vitest.Mock<() => unknown>;
|
|
2175
2132
|
setEnvironmentData: Vitest.Mock<(key: string, value: unknown) => void>;
|
|
2176
2133
|
SHARE_ENV: symbol;
|