@stratal/testing 0.0.13 → 0.0.15

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.
Files changed (155) hide show
  1. package/dist/index.d.mts +1130 -0
  2. package/dist/index.d.mts.map +1 -0
  3. package/dist/index.mjs +1788 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/dist/mocks/index.d.mts +2 -0
  6. package/dist/mocks/index.mjs +2 -0
  7. package/dist/mocks/nodemailer.d.mts +12 -0
  8. package/dist/mocks/nodemailer.d.mts.map +1 -0
  9. package/dist/mocks/nodemailer.mjs +7 -0
  10. package/dist/mocks/nodemailer.mjs.map +1 -0
  11. package/dist/mocks/zenstack-language.d.mts +48 -0
  12. package/dist/mocks/zenstack-language.d.mts.map +1 -0
  13. package/dist/mocks/zenstack-language.mjs +48 -0
  14. package/dist/mocks/zenstack-language.mjs.map +1 -0
  15. package/dist/vitest-plugin/index.d.mts +50 -0
  16. package/dist/vitest-plugin/index.d.mts.map +1 -0
  17. package/dist/vitest-plugin/index.mjs +86 -0
  18. package/dist/vitest-plugin/index.mjs.map +1 -0
  19. package/package.json +21 -19
  20. package/dist/auth/acting-as.d.ts +0 -21
  21. package/dist/auth/acting-as.d.ts.map +0 -1
  22. package/dist/auth/acting-as.js +0 -68
  23. package/dist/auth/acting-as.js.map +0 -1
  24. package/dist/auth/index.d.ts +0 -2
  25. package/dist/auth/index.d.ts.map +0 -1
  26. package/dist/auth/index.js +0 -2
  27. package/dist/auth/index.js.map +0 -1
  28. package/dist/core/env/index.d.ts +0 -2
  29. package/dist/core/env/index.d.ts.map +0 -1
  30. package/dist/core/env/index.js +0 -2
  31. package/dist/core/env/index.js.map +0 -1
  32. package/dist/core/env/test-env.d.ts +0 -9
  33. package/dist/core/env/test-env.d.ts.map +0 -1
  34. package/dist/core/env/test-env.js +0 -14
  35. package/dist/core/env/test-env.js.map +0 -1
  36. package/dist/core/http/fetch-mock.types.d.ts +0 -48
  37. package/dist/core/http/fetch-mock.types.d.ts.map +0 -1
  38. package/dist/core/http/fetch-mock.types.js +0 -2
  39. package/dist/core/http/fetch-mock.types.js.map +0 -1
  40. package/dist/core/http/index.d.ts +0 -6
  41. package/dist/core/http/index.d.ts.map +0 -1
  42. package/dist/core/http/index.js +0 -5
  43. package/dist/core/http/index.js.map +0 -1
  44. package/dist/core/http/mock-fetch.d.ts +0 -88
  45. package/dist/core/http/mock-fetch.d.ts.map +0 -1
  46. package/dist/core/http/mock-fetch.js +0 -111
  47. package/dist/core/http/mock-fetch.js.map +0 -1
  48. package/dist/core/http/test-http-client.d.ts +0 -54
  49. package/dist/core/http/test-http-client.d.ts.map +0 -1
  50. package/dist/core/http/test-http-client.js +0 -75
  51. package/dist/core/http/test-http-client.js.map +0 -1
  52. package/dist/core/http/test-http-request.d.ts +0 -60
  53. package/dist/core/http/test-http-request.d.ts.map +0 -1
  54. package/dist/core/http/test-http-request.js +0 -106
  55. package/dist/core/http/test-http-request.js.map +0 -1
  56. package/dist/core/http/test-response.d.ts +0 -161
  57. package/dist/core/http/test-response.d.ts.map +0 -1
  58. package/dist/core/http/test-response.js +0 -309
  59. package/dist/core/http/test-response.js.map +0 -1
  60. package/dist/core/index.d.ts +0 -7
  61. package/dist/core/index.d.ts.map +0 -1
  62. package/dist/core/index.js +0 -7
  63. package/dist/core/index.js.map +0 -1
  64. package/dist/core/override/index.d.ts +0 -2
  65. package/dist/core/override/index.d.ts.map +0 -1
  66. package/dist/core/override/index.js +0 -2
  67. package/dist/core/override/index.js.map +0 -1
  68. package/dist/core/override/provider-override-builder.d.ts +0 -78
  69. package/dist/core/override/provider-override-builder.d.ts.map +0 -1
  70. package/dist/core/override/provider-override-builder.js +0 -94
  71. package/dist/core/override/provider-override-builder.js.map +0 -1
  72. package/dist/core/sse/index.d.ts +0 -3
  73. package/dist/core/sse/index.d.ts.map +0 -1
  74. package/dist/core/sse/index.js +0 -3
  75. package/dist/core/sse/index.js.map +0 -1
  76. package/dist/core/sse/test-sse-connection.d.ts +0 -61
  77. package/dist/core/sse/test-sse-connection.d.ts.map +0 -1
  78. package/dist/core/sse/test-sse-connection.js +0 -233
  79. package/dist/core/sse/test-sse-connection.js.map +0 -1
  80. package/dist/core/sse/test-sse-request.d.ts +0 -42
  81. package/dist/core/sse/test-sse-request.d.ts.map +0 -1
  82. package/dist/core/sse/test-sse-request.js +0 -76
  83. package/dist/core/sse/test-sse-request.js.map +0 -1
  84. package/dist/core/test.d.ts +0 -48
  85. package/dist/core/test.d.ts.map +0 -1
  86. package/dist/core/test.js +0 -53
  87. package/dist/core/test.js.map +0 -1
  88. package/dist/core/testing-module-builder.d.ts +0 -57
  89. package/dist/core/testing-module-builder.d.ts.map +0 -1
  90. package/dist/core/testing-module-builder.js +0 -109
  91. package/dist/core/testing-module-builder.js.map +0 -1
  92. package/dist/core/testing-module.d.ts +0 -113
  93. package/dist/core/testing-module.d.ts.map +0 -1
  94. package/dist/core/testing-module.js +0 -177
  95. package/dist/core/testing-module.js.map +0 -1
  96. package/dist/core/ws/index.d.ts +0 -3
  97. package/dist/core/ws/index.d.ts.map +0 -1
  98. package/dist/core/ws/index.js +0 -3
  99. package/dist/core/ws/index.js.map +0 -1
  100. package/dist/core/ws/test-ws-connection.d.ts +0 -54
  101. package/dist/core/ws/test-ws-connection.d.ts.map +0 -1
  102. package/dist/core/ws/test-ws-connection.js +0 -119
  103. package/dist/core/ws/test-ws-connection.js.map +0 -1
  104. package/dist/core/ws/test-ws-request.d.ts +0 -43
  105. package/dist/core/ws/test-ws-request.d.ts.map +0 -1
  106. package/dist/core/ws/test-ws-request.js +0 -83
  107. package/dist/core/ws/test-ws-request.js.map +0 -1
  108. package/dist/errors/index.d.ts +0 -3
  109. package/dist/errors/index.d.ts.map +0 -1
  110. package/dist/errors/index.js +0 -3
  111. package/dist/errors/index.js.map +0 -1
  112. package/dist/errors/setup-error.d.ts +0 -9
  113. package/dist/errors/setup-error.d.ts.map +0 -1
  114. package/dist/errors/setup-error.js +0 -11
  115. package/dist/errors/setup-error.js.map +0 -1
  116. package/dist/errors/test-error.d.ts +0 -9
  117. package/dist/errors/test-error.d.ts.map +0 -1
  118. package/dist/errors/test-error.js +0 -15
  119. package/dist/errors/test-error.js.map +0 -1
  120. package/dist/index.d.ts +0 -21
  121. package/dist/index.d.ts.map +0 -1
  122. package/dist/index.js +0 -29
  123. package/dist/index.js.map +0 -1
  124. package/dist/mocks/index.d.ts +0 -3
  125. package/dist/mocks/index.d.ts.map +0 -1
  126. package/dist/mocks/index.js +0 -3
  127. package/dist/mocks/index.js.map +0 -1
  128. package/dist/mocks/nodemailer.d.ts +0 -10
  129. package/dist/mocks/nodemailer.d.ts.map +0 -1
  130. package/dist/mocks/nodemailer.js +0 -9
  131. package/dist/mocks/nodemailer.js.map +0 -1
  132. package/dist/mocks/zenstack-language.d.ts +0 -46
  133. package/dist/mocks/zenstack-language.d.ts.map +0 -1
  134. package/dist/mocks/zenstack-language.js +0 -47
  135. package/dist/mocks/zenstack-language.js.map +0 -1
  136. package/dist/storage/fake-storage.service.d.ts +0 -114
  137. package/dist/storage/fake-storage.service.d.ts.map +0 -1
  138. package/dist/storage/fake-storage.service.js +0 -233
  139. package/dist/storage/fake-storage.service.js.map +0 -1
  140. package/dist/storage/index.d.ts +0 -2
  141. package/dist/storage/index.d.ts.map +0 -1
  142. package/dist/storage/index.js +0 -2
  143. package/dist/storage/index.js.map +0 -1
  144. package/dist/types.d.ts +0 -5
  145. package/dist/types.d.ts.map +0 -1
  146. package/dist/types.js +0 -3
  147. package/dist/types.js.map +0 -1
  148. package/dist/vitest-plugin/index.d.ts +0 -2
  149. package/dist/vitest-plugin/index.d.ts.map +0 -1
  150. package/dist/vitest-plugin/index.js +0 -2
  151. package/dist/vitest-plugin/index.js.map +0 -1
  152. package/dist/vitest-plugin/stratal-test.d.ts +0 -28
  153. package/dist/vitest-plugin/stratal-test.d.ts.map +0 -1
  154. package/dist/vitest-plugin/stratal-test.js +0 -47
  155. package/dist/vitest-plugin/stratal-test.js.map +0 -1
@@ -1,21 +0,0 @@
1
- import type { AuthService } from '@stratal/framework/auth';
2
- /**
3
- * ActingAs
4
- *
5
- * Creates authentication sessions for testing.
6
- * Uses Better Auth's internalAdapter to create real database sessions.
7
- *
8
- * @example
9
- * ```typescript
10
- * const actingAs = new ActingAs(authService)
11
- * const headers = await actingAs.createSessionForUser({ id: 'user-123' })
12
- * ```
13
- */
14
- export declare class ActingAs {
15
- private readonly authService;
16
- constructor(authService: AuthService);
17
- createSessionForUser(user: {
18
- id: string;
19
- }): Promise<Headers>;
20
- }
21
- //# sourceMappingURL=acting-as.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acting-as.d.ts","sourceRoot":"","sources":["../../src/auth/acting-as.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAwB1D;;;;;;;;;;;GAWG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,EAAE,WAAW;IAE/C,oBAAoB,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC;CAkCnE"}
@@ -1,68 +0,0 @@
1
- import { setSessionCookie } from 'better-auth/cookies';
2
- import { convertSetCookieToCookie } from 'better-auth/test';
3
- async function makeSignature(value, secret) {
4
- const algorithm = { name: 'HMAC', hash: 'SHA-256' };
5
- const secretBuf = new TextEncoder().encode(secret);
6
- const key = await crypto.subtle.importKey('raw', secretBuf, algorithm, false, ['sign']);
7
- const signature = await crypto.subtle.sign(algorithm.name, key, new TextEncoder().encode(value));
8
- return btoa(String.fromCharCode(...new Uint8Array(signature)));
9
- }
10
- function buildCookieString(name, value, options = {}) {
11
- const encodedValue = encodeURIComponent(value);
12
- let str = `${name}=${encodedValue}`;
13
- if (options.path)
14
- str += `; Path=${options.path}`;
15
- if (options.httpOnly)
16
- str += '; HttpOnly';
17
- if (options.secure)
18
- str += '; Secure';
19
- if (options.sameSite)
20
- str += `; SameSite=${options.sameSite}`;
21
- if (options.maxAge !== undefined)
22
- str += `; Max-Age=${Math.floor(options.maxAge)}`;
23
- return str;
24
- }
25
- /**
26
- * ActingAs
27
- *
28
- * Creates authentication sessions for testing.
29
- * Uses Better Auth's internalAdapter to create real database sessions.
30
- *
31
- * @example
32
- * ```typescript
33
- * const actingAs = new ActingAs(authService)
34
- * const headers = await actingAs.createSessionForUser({ id: 'user-123' })
35
- * ```
36
- */
37
- export class ActingAs {
38
- authService;
39
- constructor(authService) {
40
- this.authService = authService;
41
- }
42
- async createSessionForUser(user) {
43
- const auth = this.authService.auth;
44
- const ctx = await auth.$context;
45
- const secret = ctx.secret;
46
- const session = await ctx.internalAdapter.createSession(user.id, undefined, { ipAddress: '127.0.0.1', userAgent: 'test-client' });
47
- const dbUser = await ctx.internalAdapter.findUserById(user.id);
48
- if (!dbUser) {
49
- throw new Error(`User not found: ${user.id}`);
50
- }
51
- const responseHeaders = new Headers();
52
- const mockCtx = {
53
- context: ctx,
54
- getSignedCookie: () => null,
55
- setSignedCookie: async (name, value, _secret, options = {}) => {
56
- const signature = await makeSignature(value, secret);
57
- const signedValue = `${value}.${signature}`;
58
- responseHeaders.append('Set-Cookie', buildCookieString(name, signedValue, options));
59
- },
60
- setCookie: (name, value, options = {}) => {
61
- responseHeaders.append('Set-Cookie', buildCookieString(name, value, options));
62
- },
63
- };
64
- await setSessionCookie(mockCtx, { session, user: dbUser }, false);
65
- return convertSetCookieToCookie(responseHeaders);
66
- }
67
- }
68
- //# sourceMappingURL=acting-as.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acting-as.js","sourceRoot":"","sources":["../../src/auth/acting-as.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAA;AAE3D,KAAK,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;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E,UAAmC,EAAE,EAAE,EAAE;gBAChF,eAAe,CAAC,MAAM,CAAC,YAAY,EAAE,iBAAiB,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;YAC/E,CAAC;SACF,CAAA;QAED,MAAM,gBAAgB,CAAC,OAA4C,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;QACtG,OAAO,wBAAwB,CAAC,eAAe,CAAC,CAAA;IAClD,CAAC;CACF"}
@@ -1,2 +0,0 @@
1
- export { ActingAs } from './acting-as';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export { ActingAs } from './acting-as';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
@@ -1,2 +0,0 @@
1
- export { getTestEnv } from './test-env';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -1,2 +0,0 @@
1
- export { getTestEnv } from './test-env';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/env/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -1,9 +0,0 @@
1
- import { type StratalEnv } from 'stratal';
2
- /**
3
- * Get test environment with optional overrides
4
- *
5
- * @param overrides - Optional partial env to merge with cloudflare:test env
6
- * @returns Complete Env object for testing
7
- */
8
- export declare function getTestEnv(overrides?: Partial<StratalEnv>): StratalEnv;
9
- //# sourceMappingURL=test-env.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-env.d.ts","sourceRoot":"","sources":["../../../src/core/env/test-env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAA;AAGzC;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAKtE"}
@@ -1,14 +0,0 @@
1
- import { env as cloudflareEnv } from 'cloudflare:workers';
2
- /**
3
- * Get test environment with optional overrides
4
- *
5
- * @param overrides - Optional partial env to merge with cloudflare:test env
6
- * @returns Complete Env object for testing
7
- */
8
- export function getTestEnv(overrides) {
9
- return {
10
- ...cloudflareEnv,
11
- ...overrides,
12
- };
13
- }
14
- //# sourceMappingURL=test-env.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-env.js","sourceRoot":"","sources":["../../../src/core/env/test-env.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,IAAI,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEzD;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CAAC,SAA+B;IACxD,OAAO;QACL,GAAG,aAAa;QAChB,GAAG,SAAS;KACC,CAAA;AACjB,CAAC"}
@@ -1,48 +0,0 @@
1
- /**
2
- * Options for mocking JSON responses
3
- */
4
- export interface MockJsonOptions {
5
- /**
6
- * HTTP status code for the response
7
- * @default 200
8
- */
9
- status?: number;
10
- /**
11
- * Custom headers to include in the response
12
- */
13
- headers?: Record<string, string>;
14
- /**
15
- * Delay in milliseconds before responding
16
- */
17
- delay?: number;
18
- /**
19
- * HTTP method to match (GET, POST, PUT, PATCH, DELETE, etc.)
20
- * @default 'GET'
21
- */
22
- method?: string;
23
- /**
24
- * Specific path to override URL pathname
25
- * If not provided, the pathname from the URL will be used
26
- */
27
- path?: string;
28
- }
29
- /**
30
- * Options for mocking error responses
31
- */
32
- export interface MockErrorOptions {
33
- /**
34
- * Custom headers to include in the error response
35
- */
36
- headers?: Record<string, string>;
37
- /**
38
- * HTTP method to match (GET, POST, PUT, PATCH, DELETE, etc.)
39
- * @default 'GET'
40
- */
41
- method?: string;
42
- /**
43
- * Specific path to override URL pathname
44
- * If not provided, the pathname from the URL will be used
45
- */
46
- path?: string;
47
- }
48
- //# sourceMappingURL=fetch-mock.types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-mock.types.d.ts","sourceRoot":"","sources":["../../../src/core/http/fetch-mock.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,eAAe;IAC/B;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAChC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAEhC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACb"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=fetch-mock.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fetch-mock.types.js","sourceRoot":"","sources":["../../../src/core/http/fetch-mock.types.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- export { TestHttpClient } from './test-http-client';
2
- export { TestHttpRequest } from './test-http-request';
3
- export { TestResponse } from './test-response';
4
- export { MockFetch, createMockFetch } from './mock-fetch';
5
- export type { MockJsonOptions, MockErrorOptions } from './fetch-mock.types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACzD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,5 +0,0 @@
1
- export { TestHttpClient } from './test-http-client';
2
- export { TestHttpRequest } from './test-http-request';
3
- export { TestResponse } from './test-response';
4
- export { MockFetch, createMockFetch } from './mock-fetch';
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/http/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA"}
@@ -1,88 +0,0 @@
1
- import { type RequestHandler } from 'msw';
2
- import type { MockErrorOptions, MockJsonOptions } from './fetch-mock.types';
3
- /**
4
- * MSW-based fetch mock for declarative HTTP mocking in tests.
5
- *
6
- * Replaces the old Cloudflare `fetchMock` (undici MockAgent) with MSW's `setupServer`.
7
- * Works in both Node.js and workerd test environments.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { createMockFetch } from '@stratal/testing'
12
- *
13
- * const mock = createMockFetch()
14
- *
15
- * beforeAll(() => mock.listen())
16
- * afterEach(() => mock.reset())
17
- * afterAll(() => mock.close())
18
- *
19
- * it('should mock external API', async () => {
20
- * mock.mockJsonResponse('https://api.example.com/data', { success: true })
21
- *
22
- * const response = await fetch('https://api.example.com/data')
23
- * const json = await response.json()
24
- *
25
- * expect(json.success).toBe(true)
26
- * })
27
- * ```
28
- */
29
- export declare class MockFetch {
30
- private server;
31
- constructor(handlers?: RequestHandler[]);
32
- /** Start intercepting. Call in beforeAll/beforeEach. */
33
- listen(): void;
34
- /** Reset runtime handlers. Call in afterEach. */
35
- reset(): void;
36
- /** Stop intercepting. Call in afterAll. */
37
- close(): void;
38
- /** Add runtime handler(s) for a single test. */
39
- use(...handlers: RequestHandler[]): void;
40
- /**
41
- * Mock a JSON response.
42
- *
43
- * @param url - Full URL to mock (e.g., 'https://api.example.com/users')
44
- * @param data - JSON data to return
45
- * @param options - HTTP method, status code, headers
46
- *
47
- * @example
48
- * ```typescript
49
- * mock.mockJsonResponse('https://api.example.com/users', { users: [] })
50
- * mock.mockJsonResponse('https://api.example.com/users', { created: true }, { method: 'POST', status: 201 })
51
- * ```
52
- */
53
- mockJsonResponse(url: string, data: Record<string, unknown> | unknown[], options?: MockJsonOptions): void;
54
- /**
55
- * Mock an error response.
56
- *
57
- * @param url - Full URL to mock
58
- * @param status - HTTP error status code
59
- * @param message - Optional error message
60
- * @param options - HTTP method, headers
61
- *
62
- * @example
63
- * ```typescript
64
- * mock.mockError('https://api.example.com/fail', 401, 'Unauthorized')
65
- * mock.mockError('https://api.example.com/fail', 500, 'Server Error', { method: 'POST' })
66
- * ```
67
- */
68
- mockError(url: string, status: number, message?: string, options?: MockErrorOptions): void;
69
- }
70
- /**
71
- * Factory function to create a new MockFetch instance
72
- *
73
- * @param handlers - Optional initial MSW request handlers
74
- * @returns A new MockFetch instance
75
- *
76
- * @example
77
- * ```typescript
78
- * import { createMockFetch } from '@stratal/testing'
79
- *
80
- * const mock = createMockFetch()
81
- *
82
- * beforeAll(() => mock.listen())
83
- * afterEach(() => mock.reset())
84
- * afterAll(() => mock.close())
85
- * ```
86
- */
87
- export declare function createMockFetch(handlers?: RequestHandler[]): MockFetch;
88
- //# sourceMappingURL=mock-fetch.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-fetch.d.ts","sourceRoot":"","sources":["../../../src/core/http/mock-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAE7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAI3E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAa;gBAEf,QAAQ,GAAE,cAAc,EAAO;IAI3C,wDAAwD;IACxD,MAAM;IAIN,iDAAiD;IACjD,KAAK;IAIL,2CAA2C;IAC3C,KAAK;IAIL,gDAAgD;IAChD,GAAG,CAAC,GAAG,QAAQ,EAAE,cAAc,EAAE;IAIjC;;;;;;;;;;;;OAYG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,EAAE,OAAO,GAAE,eAAoB;IAWtG;;;;;;;;;;;;;OAaG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB;CASxF;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,GAAG,SAAS,CAEtE"}
@@ -1,111 +0,0 @@
1
- import { http, HttpResponse } from 'msw';
2
- import { setupServer } from 'msw/node';
3
- /**
4
- * MSW-based fetch mock for declarative HTTP mocking in tests.
5
- *
6
- * Replaces the old Cloudflare `fetchMock` (undici MockAgent) with MSW's `setupServer`.
7
- * Works in both Node.js and workerd test environments.
8
- *
9
- * @example
10
- * ```typescript
11
- * import { createMockFetch } from '@stratal/testing'
12
- *
13
- * const mock = createMockFetch()
14
- *
15
- * beforeAll(() => mock.listen())
16
- * afterEach(() => mock.reset())
17
- * afterAll(() => mock.close())
18
- *
19
- * it('should mock external API', async () => {
20
- * mock.mockJsonResponse('https://api.example.com/data', { success: true })
21
- *
22
- * const response = await fetch('https://api.example.com/data')
23
- * const json = await response.json()
24
- *
25
- * expect(json.success).toBe(true)
26
- * })
27
- * ```
28
- */
29
- export class MockFetch {
30
- server;
31
- constructor(handlers = []) {
32
- this.server = setupServer(...handlers);
33
- }
34
- /** Start intercepting. Call in beforeAll/beforeEach. */
35
- listen() {
36
- this.server.listen({ onUnhandledRequest: 'error' });
37
- }
38
- /** Reset runtime handlers. Call in afterEach. */
39
- reset() {
40
- this.server.resetHandlers();
41
- }
42
- /** Stop intercepting. Call in afterAll. */
43
- close() {
44
- this.server.close();
45
- }
46
- /** Add runtime handler(s) for a single test. */
47
- use(...handlers) {
48
- this.server.use(...handlers);
49
- }
50
- /**
51
- * Mock a JSON response.
52
- *
53
- * @param url - Full URL to mock (e.g., 'https://api.example.com/users')
54
- * @param data - JSON data to return
55
- * @param options - HTTP method, status code, headers
56
- *
57
- * @example
58
- * ```typescript
59
- * mock.mockJsonResponse('https://api.example.com/users', { users: [] })
60
- * mock.mockJsonResponse('https://api.example.com/users', { created: true }, { method: 'POST', status: 201 })
61
- * ```
62
- */
63
- mockJsonResponse(url, data, options = {}) {
64
- const method = (options.method ?? 'GET').toLowerCase();
65
- const handler = http[method](url, () => HttpResponse.json(data, {
66
- status: options.status ?? 200,
67
- headers: options.headers,
68
- }));
69
- this.server.use(handler);
70
- }
71
- /**
72
- * Mock an error response.
73
- *
74
- * @param url - Full URL to mock
75
- * @param status - HTTP error status code
76
- * @param message - Optional error message
77
- * @param options - HTTP method, headers
78
- *
79
- * @example
80
- * ```typescript
81
- * mock.mockError('https://api.example.com/fail', 401, 'Unauthorized')
82
- * mock.mockError('https://api.example.com/fail', 500, 'Server Error', { method: 'POST' })
83
- * ```
84
- */
85
- mockError(url, status, message, options = {}) {
86
- const method = (options.method ?? 'GET').toLowerCase();
87
- const body = message ? { error: message } : undefined;
88
- this.server.use(http[method](url, () => HttpResponse.json(body, { status, headers: options.headers })));
89
- }
90
- }
91
- /**
92
- * Factory function to create a new MockFetch instance
93
- *
94
- * @param handlers - Optional initial MSW request handlers
95
- * @returns A new MockFetch instance
96
- *
97
- * @example
98
- * ```typescript
99
- * import { createMockFetch } from '@stratal/testing'
100
- *
101
- * const mock = createMockFetch()
102
- *
103
- * beforeAll(() => mock.listen())
104
- * afterEach(() => mock.reset())
105
- * afterAll(() => mock.close())
106
- * ```
107
- */
108
- export function createMockFetch(handlers) {
109
- return new MockFetch(handlers);
110
- }
111
- //# sourceMappingURL=mock-fetch.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mock-fetch.js","sourceRoot":"","sources":["../../../src/core/http/mock-fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAuB,MAAM,KAAK,CAAA;AAC7D,OAAO,EAAE,WAAW,EAAoB,MAAM,UAAU,CAAA;AAKxD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,SAAS;IACZ,MAAM,CAAa;IAE3B,YAAY,WAA6B,EAAE;QACzC,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC,GAAG,QAAQ,CAAC,CAAA;IACxC,CAAC;IAED,wDAAwD;IACxD,MAAM;QACJ,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAA;IACrD,CAAC;IAED,iDAAiD;IACjD,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAA;IAC7B,CAAC;IAED,2CAA2C;IAC3C,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EA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AS,CAAC,QAAQ,CAAC,CAAA;AAChC,CAAC"}
@@ -1,54 +0,0 @@
1
- import type { TestingModule } from '../testing-module';
2
- import { TestHttpRequest } from './test-http-request';
3
- /**
4
- * TestHttpClient
5
- *
6
- * Fluent HTTP client for making test requests.
7
- *
8
- * @example
9
- * ```typescript
10
- * const response = await module.http
11
- * .forHost('example.com')
12
- * .post('/api/v1/users')
13
- * .withBody({ name: 'Test' })
14
- * .send()
15
- *
16
- * response.assertCreated()
17
- * ```
18
- */
19
- export declare class TestHttpClient {
20
- private readonly module;
21
- private defaultHeaders;
22
- private host;
23
- constructor(module: TestingModule);
24
- /**
25
- * Set the host for the request
26
- */
27
- forHost(host: string): this;
28
- /**
29
- * Set default headers for all requests
30
- */
31
- withHeaders(headers: Record<string, string>): this;
32
- /**
33
- * Create a GET request
34
- */
35
- get(path: string): TestHttpRequest;
36
- /**
37
- * Create a POST request
38
- */
39
- post(path: string): TestHttpRequest;
40
- /**
41
- * Create a PUT request
42
- */
43
- put(path: string): TestHttpRequest;
44
- /**
45
- * Create a PATCH request
46
- */
47
- patch(path: string): TestHttpRequest;
48
- /**
49
- * Create a DELETE request
50
- */
51
- delete(path: string): TestHttpRequest;
52
- private createRequest;
53
- }
54
- //# sourceMappingURL=test-http-client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-client.d.ts","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,cAAc;IAIb,OAAO,CAAC,QAAQ,CAAC,MAAM;IAHnC,OAAO,CAAC,cAAc,CAAyB;IAC/C,OAAO,CAAC,IAAI,CAAsB;gBAEL,MAAM,EAAE,aAAa;IAElD;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK3B;;OAEG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAOlD;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAInC;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIlC;;OAEG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIpC;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe;IAIrC,OAAO,CAAC,aAAa;CAGtB"}
@@ -1,75 +0,0 @@
1
- import { TestHttpRequest } from './test-http-request';
2
- /**
3
- * TestHttpClient
4
- *
5
- * Fluent HTTP client for making test requests.
6
- *
7
- * @example
8
- * ```typescript
9
- * const response = await module.http
10
- * .forHost('example.com')
11
- * .post('/api/v1/users')
12
- * .withBody({ name: 'Test' })
13
- * .send()
14
- *
15
- * response.assertCreated()
16
- * ```
17
- */
18
- export class TestHttpClient {
19
- module;
20
- defaultHeaders = new Headers();
21
- host = null;
22
- constructor(module) {
23
- this.module = module;
24
- }
25
- /**
26
- * Set the host for the request
27
- */
28
- forHost(host) {
29
- this.host = host;
30
- return this;
31
- }
32
- /**
33
- * Set default headers for all requests
34
- */
35
- withHeaders(headers) {
36
- for (const [key, value] of Object.entries(headers)) {
37
- this.defaultHeaders.set(key, value);
38
- }
39
- return this;
40
- }
41
- /**
42
- * Create a GET request
43
- */
44
- get(path) {
45
- return this.createRequest('GET', path);
46
- }
47
- /**
48
- * Create a POST request
49
- */
50
- post(path) {
51
- return this.createRequest('POST', path);
52
- }
53
- /**
54
- * Create a PUT request
55
- */
56
- put(path) {
57
- return this.createRequest('PUT', path);
58
- }
59
- /**
60
- * Create a PATCH request
61
- */
62
- patch(path) {
63
- return this.createRequest('PATCH', path);
64
- }
65
- /**
66
- * Create a DELETE request
67
- */
68
- delete(path) {
69
- return this.createRequest('DELETE', path);
70
- }
71
- createRequest(method, path) {
72
- return new TestHttpRequest(method, path, this.defaultHeaders, this.module, this.host);
73
- }
74
- }
75
- //# sourceMappingURL=test-http-client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test-http-client.js","sourceRoot":"","sources":["../../../src/core/http/test-http-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAErD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,cAAc;IAII;IAHrB,cAAc,GAAY,IAAI,OAAO,EAAE,CAAA;IACvC,IAAI,GAAkB,IAAI,CAAA;IAElC,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAI,CAAC;IAEvD;;OAEG;IACH,OAAO,CAAC,IAAY;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,OAA+B;QACzC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;YACnD,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACrC,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,CAAC,IAAY;QACf,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAY;QAChB,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACjB,OAAO,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAC3C,CAAC;IAEO,aAAa,CAAC,MAAc,EAAE,IAAY;QAChD,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACvF,CAAC;CACF"}
@@ -1,60 +0,0 @@
1
- import type { TestingModule } from '../testing-module';
2
- import { TestResponse } from './test-response';
3
- /**
4
- * TestHttpRequest
5
- *
6
- * Request builder with fluent API for configuring test HTTP requests.
7
- *
8
- * @example
9
- * ```typescript
10
- * const response = await module.http
11
- * .post('/api/v1/register')
12
- * .withBody({ name: 'Test School' })
13
- * .withHeaders({ 'X-Custom': 'value' })
14
- * .send()
15
- * ```
16
- *
17
- * @example Authenticated request
18
- * ```typescript
19
- * const response = await module.http
20
- * .get('/api/v1/profile')
21
- * .actingAs({ id: user.id })
22
- * .send()
23
- * ```
24
- */
25
- export declare class TestHttpRequest {
26
- private readonly method;
27
- private readonly path;
28
- private readonly module;
29
- private readonly host;
30
- private body;
31
- private requestHeaders;
32
- private actingAsUser;
33
- constructor(method: string, path: string, headers: Headers, module: TestingModule, host?: string | null);
34
- /**
35
- * Set the request body
36
- */
37
- withBody(data: unknown): this;
38
- /**
39
- * Add headers to the request
40
- */
41
- withHeaders(headers: Record<string, string>): this;
42
- /**
43
- * Set Content-Type to application/json
44
- */
45
- asJson(): this;
46
- /**
47
- * Authenticate the request as a specific user
48
- */
49
- actingAs(user: {
50
- id: string;
51
- }): this;
52
- /**
53
- * Send the request and return response
54
- *
55
- * Calls module.fetch() - NOT SELF.fetch()
56
- */
57
- send(): Promise<TestResponse>;
58
- private applyAuthentication;
59
- }
60
- //# sourceMappingURL=test-http-request.d.ts.map