@cedarjs/testing 9.0.0-canary.1784 → 9.0.0-canary.3124

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 (244) hide show
  1. package/dist/api/checkTestDatabase.d.ts +23 -0
  2. package/dist/api/checkTestDatabase.d.ts.map +1 -0
  3. package/dist/api/checkTestDatabase.js +44 -0
  4. package/dist/api/index.d.ts +0 -1
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/api/index.js +0 -1
  7. package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
  8. package/dist/api/vitest/CedarApiVitestEnv.js +22 -17
  9. package/dist/api/vitest/teardown.d.ts +18 -0
  10. package/dist/api/vitest/teardown.d.ts.map +1 -0
  11. package/dist/api/vitest/teardown.js +43 -0
  12. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +1 -1
  13. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +13 -8
  14. package/dist/api/vitest/vitest-api.setup.d.ts.map +1 -1
  15. package/dist/api/vitest/vitest-api.setup.js +18 -33
  16. package/dist/cache/index.js +1 -1
  17. package/dist/web/MockParamsProvider.d.ts.map +1 -1
  18. package/dist/web/MockParamsProvider.js +10 -1
  19. package/dist/web/MockProviders.js +12 -6
  20. package/dist/web/MockRouter.d.ts.map +1 -1
  21. package/dist/web/mockRequests.d.ts +74 -18
  22. package/dist/web/mockRequests.d.ts.map +1 -1
  23. package/dist/web/mockRequests.js +118 -39
  24. package/dist/web/vitest/index.d.ts +1 -0
  25. package/dist/web/vitest/index.d.ts.map +1 -1
  26. package/dist/web/vitest/index.js +2 -0
  27. package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts +12 -0
  28. package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts.map +1 -0
  29. package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.js +16 -0
  30. package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +1 -1
  31. package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +1 -1
  32. package/dist/web/vitest/vitest-web.setup.d.ts +2 -0
  33. package/dist/web/vitest/vitest-web.setup.d.ts.map +1 -0
  34. package/dist/web/vitest/vitest-web.setup.js +18 -0
  35. package/package.json +41 -106
  36. package/LICENSE +0 -21
  37. package/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  38. package/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  39. package/config/jest/api/RedwoodApiJestEnv.js +0 -48
  40. package/config/jest/api/apiBabelConfig.d.ts +0 -5
  41. package/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  42. package/config/jest/api/apiBabelConfig.js +0 -34
  43. package/config/jest/api/globalSetup.d.ts +0 -3
  44. package/config/jest/api/globalSetup.d.ts.map +0 -1
  45. package/config/jest/api/globalSetup.js +0 -63
  46. package/config/jest/api/index.d.ts +0 -3
  47. package/config/jest/api/index.d.ts.map +0 -1
  48. package/config/jest/api/index.js +0 -25
  49. package/config/jest/api/jest-preset.d.ts +0 -4
  50. package/config/jest/api/jest-preset.d.ts.map +0 -1
  51. package/config/jest/api/jest-preset.js +0 -99
  52. package/config/jest/api/jest.setup.d.ts +0 -2
  53. package/config/jest/api/jest.setup.d.ts.map +0 -1
  54. package/config/jest/api/jest.setup.js +0 -271
  55. package/config/jest/api/package.json +0 -8
  56. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  57. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  58. package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -121
  59. package/config/jest/jest-serial-runner.d.ts +0 -8
  60. package/config/jest/jest-serial-runner.d.ts.map +0 -1
  61. package/config/jest/jest-serial-runner.js +0 -37
  62. package/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  63. package/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  64. package/config/jest/web/RedwoodWebJestEnv.js +0 -38
  65. package/config/jest/web/index.d.ts +0 -3
  66. package/config/jest/web/index.d.ts.map +0 -1
  67. package/config/jest/web/index.js +0 -25
  68. package/config/jest/web/jest-preset.d.ts +0 -4
  69. package/config/jest/web/jest-preset.d.ts.map +0 -1
  70. package/config/jest/web/jest-preset.js +0 -119
  71. package/config/jest/web/jest.setup.d.ts +0 -8
  72. package/config/jest/web/jest.setup.d.ts.map +0 -1
  73. package/config/jest/web/jest.setup.js +0 -22
  74. package/config/jest/web/package.json +0 -8
  75. package/config/jest/web/resolver.d.ts +0 -4
  76. package/config/jest/web/resolver.d.ts.map +0 -1
  77. package/config/jest/web/resolver.js +0 -30
  78. package/config/jest/web/webBabelConfig.d.ts +0 -10
  79. package/config/jest/web/webBabelConfig.d.ts.map +0 -1
  80. package/config/jest/web/webBabelConfig.js +0 -48
  81. package/config/package.json +0 -1
  82. package/dist/api/directUrlHelpers.d.ts +0 -3
  83. package/dist/api/directUrlHelpers.d.ts.map +0 -1
  84. package/dist/api/directUrlHelpers.js +0 -25
  85. package/dist/cjs/api/apiFunction.d.ts +0 -37
  86. package/dist/cjs/api/apiFunction.d.ts.map +0 -1
  87. package/dist/cjs/api/apiFunction.js +0 -89
  88. package/dist/cjs/api/directUrlHelpers.d.ts +0 -3
  89. package/dist/cjs/api/directUrlHelpers.d.ts.map +0 -1
  90. package/dist/cjs/api/directUrlHelpers.js +0 -60
  91. package/dist/cjs/api/directive.d.ts +0 -51
  92. package/dist/cjs/api/directive.d.ts.map +0 -1
  93. package/dist/cjs/api/directive.js +0 -77
  94. package/dist/cjs/api/index.d.ts +0 -5
  95. package/dist/cjs/api/index.d.ts.map +0 -1
  96. package/dist/cjs/api/index.js +0 -28
  97. package/dist/cjs/api/mockContext.d.ts +0 -5
  98. package/dist/cjs/api/mockContext.d.ts.map +0 -1
  99. package/dist/cjs/api/mockContext.js +0 -58
  100. package/dist/cjs/api/scenario.d.ts +0 -108
  101. package/dist/cjs/api/scenario.d.ts.map +0 -1
  102. package/dist/cjs/api/scenario.js +0 -30
  103. package/dist/cjs/api/vitest/CedarApiVitestEnv.js +0 -73
  104. package/dist/cjs/api/vitest/index.js +0 -34
  105. package/dist/cjs/api/vitest/vite-plugin-auto-import.js +0 -71
  106. package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -69
  107. package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +0 -47
  108. package/dist/cjs/api/vitest/vitest-api.setup.js +0 -272
  109. package/dist/cjs/cache/index.d.ts +0 -50
  110. package/dist/cjs/cache/index.d.ts.map +0 -1
  111. package/dist/cjs/cache/index.js +0 -104
  112. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  113. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  114. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +0 -48
  115. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +0 -5
  116. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  117. package/dist/cjs/config/jest/api/apiBabelConfig.js +0 -34
  118. package/dist/cjs/config/jest/api/globalSetup.d.ts +0 -3
  119. package/dist/cjs/config/jest/api/globalSetup.d.ts.map +0 -1
  120. package/dist/cjs/config/jest/api/globalSetup.js +0 -63
  121. package/dist/cjs/config/jest/api/index.d.ts +0 -3
  122. package/dist/cjs/config/jest/api/index.d.ts.map +0 -1
  123. package/dist/cjs/config/jest/api/index.js +0 -25
  124. package/dist/cjs/config/jest/api/jest-preset.d.ts +0 -4
  125. package/dist/cjs/config/jest/api/jest-preset.d.ts.map +0 -1
  126. package/dist/cjs/config/jest/api/jest-preset.js +0 -99
  127. package/dist/cjs/config/jest/api/jest.setup.d.ts +0 -2
  128. package/dist/cjs/config/jest/api/jest.setup.d.ts.map +0 -1
  129. package/dist/cjs/config/jest/api/jest.setup.js +0 -271
  130. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  131. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  132. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -121
  133. package/dist/cjs/config/jest/jest-serial-runner.d.ts +0 -8
  134. package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +0 -1
  135. package/dist/cjs/config/jest/jest-serial-runner.js +0 -37
  136. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  137. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  138. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +0 -38
  139. package/dist/cjs/config/jest/web/index.d.ts +0 -3
  140. package/dist/cjs/config/jest/web/index.d.ts.map +0 -1
  141. package/dist/cjs/config/jest/web/index.js +0 -25
  142. package/dist/cjs/config/jest/web/jest-preset.d.ts +0 -4
  143. package/dist/cjs/config/jest/web/jest-preset.d.ts.map +0 -1
  144. package/dist/cjs/config/jest/web/jest-preset.js +0 -119
  145. package/dist/cjs/config/jest/web/jest.setup.d.ts +0 -8
  146. package/dist/cjs/config/jest/web/jest.setup.d.ts.map +0 -1
  147. package/dist/cjs/config/jest/web/jest.setup.js +0 -22
  148. package/dist/cjs/config/jest/web/resolver.d.ts +0 -4
  149. package/dist/cjs/config/jest/web/resolver.d.ts.map +0 -1
  150. package/dist/cjs/config/jest/web/resolver.js +0 -30
  151. package/dist/cjs/config/jest/web/webBabelConfig.d.ts +0 -10
  152. package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +0 -1
  153. package/dist/cjs/config/jest/web/webBabelConfig.js +0 -48
  154. package/dist/cjs/package.json +0 -1
  155. package/dist/cjs/web/MockParamsProvider.d.ts +0 -7
  156. package/dist/cjs/web/MockParamsProvider.d.ts.map +0 -1
  157. package/dist/cjs/web/MockParamsProvider.js +0 -44
  158. package/dist/cjs/web/MockProviders.d.ts +0 -5
  159. package/dist/cjs/web/MockProviders.d.ts.map +0 -1
  160. package/dist/cjs/web/MockProviders.js +0 -60
  161. package/dist/cjs/web/MockRouter.d.ts +0 -11
  162. package/dist/cjs/web/MockRouter.d.ts.map +0 -1
  163. package/dist/cjs/web/MockRouter.js +0 -48
  164. package/dist/cjs/web/customRender.d.ts +0 -6
  165. package/dist/cjs/web/customRender.d.ts.map +0 -1
  166. package/dist/cjs/web/customRender.js +0 -54
  167. package/dist/cjs/web/fileMock.d.ts +0 -9
  168. package/dist/cjs/web/fileMock.d.ts.map +0 -1
  169. package/dist/cjs/web/fileMock.js +0 -24
  170. package/dist/cjs/web/findCellMocks.d.ts +0 -2
  171. package/dist/cjs/web/findCellMocks.d.ts.map +0 -1
  172. package/dist/cjs/web/findCellMocks.js +0 -45
  173. package/dist/cjs/web/globRoutesImporter.d.ts +0 -13
  174. package/dist/cjs/web/globRoutesImporter.d.ts.map +0 -1
  175. package/dist/cjs/web/globRoutesImporter.js +0 -46
  176. package/dist/cjs/web/global.d.ts +0 -6
  177. package/dist/cjs/web/global.d.ts.map +0 -1
  178. package/dist/cjs/web/global.js +0 -1
  179. package/dist/cjs/web/index.d.ts +0 -6
  180. package/dist/cjs/web/index.d.ts.map +0 -1
  181. package/dist/cjs/web/index.js +0 -41
  182. package/dist/cjs/web/mockAuth.d.ts +0 -29
  183. package/dist/cjs/web/mockAuth.d.ts.map +0 -1
  184. package/dist/cjs/web/mockAuth.js +0 -89
  185. package/dist/cjs/web/mockRequests.d.ts +0 -30
  186. package/dist/cjs/web/mockRequests.d.ts.map +0 -1
  187. package/dist/cjs/web/mockRequests.js +0 -139
  188. package/dist/cjs/web/vitest/index.d.ts +0 -4
  189. package/dist/cjs/web/vitest/index.d.ts.map +0 -1
  190. package/dist/cjs/web/vitest/index.js +0 -34
  191. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts +0 -2
  192. package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts.map +0 -1
  193. package/dist/cjs/web/vitest/vite-plugin-auto-import.js +0 -60
  194. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +0 -7
  195. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +0 -1
  196. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -42
  197. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts +0 -3
  198. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +0 -1
  199. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +0 -43
  200. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  201. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  202. package/dist/config/jest/api/RedwoodApiJestEnv.js +0 -28
  203. package/dist/config/jest/api/apiBabelConfig.d.ts +0 -5
  204. package/dist/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  205. package/dist/config/jest/api/apiBabelConfig.js +0 -18
  206. package/dist/config/jest/api/globalSetup.d.ts +0 -3
  207. package/dist/config/jest/api/globalSetup.d.ts.map +0 -1
  208. package/dist/config/jest/api/globalSetup.js +0 -36
  209. package/dist/config/jest/api/index.d.ts +0 -3
  210. package/dist/config/jest/api/index.d.ts.map +0 -1
  211. package/dist/config/jest/api/index.js +0 -11
  212. package/dist/config/jest/api/jest-preset.d.ts +0 -4
  213. package/dist/config/jest/api/jest-preset.d.ts.map +0 -1
  214. package/dist/config/jest/api/jest-preset.js +0 -69
  215. package/dist/config/jest/api/jest.setup.d.ts +0 -2
  216. package/dist/config/jest/api/jest.setup.d.ts.map +0 -1
  217. package/dist/config/jest/api/jest.setup.js +0 -248
  218. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  219. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  220. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -101
  221. package/dist/config/jest/jest-serial-runner.d.ts +0 -8
  222. package/dist/config/jest/jest-serial-runner.d.ts.map +0 -1
  223. package/dist/config/jest/jest-serial-runner.js +0 -23
  224. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  225. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  226. package/dist/config/jest/web/RedwoodWebJestEnv.js +0 -18
  227. package/dist/config/jest/web/index.d.ts +0 -3
  228. package/dist/config/jest/web/index.d.ts.map +0 -1
  229. package/dist/config/jest/web/index.js +0 -11
  230. package/dist/config/jest/web/jest-preset.d.ts +0 -4
  231. package/dist/config/jest/web/jest-preset.d.ts.map +0 -1
  232. package/dist/config/jest/web/jest-preset.js +0 -89
  233. package/dist/config/jest/web/jest.setup.d.ts +0 -8
  234. package/dist/config/jest/web/jest.setup.d.ts.map +0 -1
  235. package/dist/config/jest/web/jest.setup.js +0 -28
  236. package/dist/config/jest/web/resolver.d.ts +0 -4
  237. package/dist/config/jest/web/resolver.d.ts.map +0 -1
  238. package/dist/config/jest/web/resolver.js +0 -38
  239. package/dist/config/jest/web/webBabelConfig.d.ts +0 -10
  240. package/dist/config/jest/web/webBabelConfig.d.ts.map +0 -1
  241. package/dist/config/jest/web/webBabelConfig.js +0 -18
  242. package/dist/web/fileMock.d.ts +0 -9
  243. package/dist/web/fileMock.d.ts.map +0 -1
  244. package/dist/web/fileMock.js +0 -4
@@ -1,51 +0,0 @@
1
- import type { A } from 'ts-toolbelt';
2
- import type { DirectiveParams, ValidatorDirective, TransformerDirective } from '@cedarjs/graphql-server';
3
- export { getDirectiveName } from '@cedarjs/graphql-server';
4
- interface DirectiveMocker {
5
- (directive: ValidatorDirective, executionMock: A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>>): any;
6
- }
7
- type TransformerMock = A.Compute<Omit<Partial<DirectiveParams>, 'resolvedValue'>> & {
8
- mockedResolvedValue: any;
9
- };
10
- interface DirectiveMocker {
11
- (directive: TransformerDirective, executionMock: TransformerMock): any;
12
- }
13
- /**
14
- * @description
15
- *
16
- * Used for writing both synchronous and asynchronous directive tests e.g.
17
- *
18
- * - Transformer directives can be passed mockedResolvedValue
19
- * - Validator directives should check for errors thrown in certain situations
20
- * - Can provide args, directiveArgs and context to mock directive execution
21
- *
22
- * @example
23
- *
24
- * Synchronous transformer directive:
25
- *
26
- * ```ts
27
- * const mockExecution = mockRedwoodDirective(myTransformer, {
28
- * context: currentUser,
29
- * mockedResolvedValue: 'Original Value',
30
- * })
31
- *
32
- * expect(mockExecution).not.toThrow()
33
- * expect(mockExecution()).toEqual('Transformed Value')
34
- * ```ts
35
- *
36
- * @example
37
- *
38
- * Asynchronous transformer directive:
39
- *
40
- * ```ts
41
- * const mockExecution = mockRedwoodDirective(myTransformer, {
42
- * context: currentUser,
43
- * mockedResolvedValue: 'Original Value',
44
- * })
45
- *
46
- * await expect(mockExecution).resolves.not.toThrow()
47
- * await expect(mockExecution()).resolves.toEqual('Transformed Value')
48
- * ```
49
- */
50
- export declare const mockRedwoodDirective: DirectiveMocker;
51
- //# sourceMappingURL=directive.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../../src/api/directive.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,aAAa,CAAA;AAGpC,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,yBAAyB,CAAA;AAGhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAG1D,UAAU,eAAe;IACvB,CACE,SAAS,EAAE,kBAAkB,EAC7B,aAAa,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAAC,GACxE,GAAG,CAAA;CACP;AAED,KAAK,eAAe,GAAG,CAAC,CAAC,OAAO,CAC9B,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC,CAChD,GAAG;IACF,mBAAmB,EAAE,GAAG,CAAA;CACzB,CAAA;AAGD,UAAU,eAAe;IACvB,CAAC,SAAS,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,GAAG,GAAG,CAAA;CACvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,oBAAoB,EAAE,eAmDlC,CAAA"}
@@ -1,77 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var directive_exports = {};
20
- __export(directive_exports, {
21
- getDirectiveName: () => import_graphql_server2.getDirectiveName,
22
- mockRedwoodDirective: () => mockRedwoodDirective
23
- });
24
- module.exports = __toCommonJS(directive_exports);
25
- var import_context = require("@cedarjs/context");
26
- var import_graphql_server = require("@cedarjs/graphql-server");
27
- var import_graphql_server2 = require("@cedarjs/graphql-server");
28
- const mockRedwoodDirective = (directive, executionMock) => {
29
- const { directiveArgs, context, ...others } = executionMock;
30
- if (directive.onResolvedValue.constructor.name === "AsyncFunction") {
31
- return async () => {
32
- if (context !== void 0) {
33
- (0, import_context.setContext)(context);
34
- }
35
- if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
36
- const { mockedResolvedValue } = others;
37
- return directive.onResolvedValue({
38
- resolvedValue: mockedResolvedValue,
39
- directiveArgs: directiveArgs ?? {},
40
- context: import_context.context,
41
- ...others
42
- });
43
- } else {
44
- await directive.onResolvedValue({
45
- directiveArgs: directiveArgs ?? {},
46
- context: import_context.context,
47
- ...others
48
- });
49
- }
50
- };
51
- }
52
- return () => {
53
- if (context !== void 0) {
54
- (0, import_context.setContext)(context);
55
- }
56
- if (directive.type === import_graphql_server.DirectiveType.TRANSFORMER) {
57
- const { mockedResolvedValue } = others;
58
- return directive.onResolvedValue({
59
- resolvedValue: mockedResolvedValue,
60
- directiveArgs: directiveArgs ?? {},
61
- context: import_context.context,
62
- ...others
63
- });
64
- } else {
65
- directive.onResolvedValue({
66
- directiveArgs: directiveArgs ?? {},
67
- context: import_context.context,
68
- ...others
69
- });
70
- }
71
- };
72
- };
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {
75
- getDirectiveName,
76
- mockRedwoodDirective
77
- });
@@ -1,5 +0,0 @@
1
- export * from './apiFunction.js';
2
- export * from './scenario.js';
3
- export * from './directive.js';
4
- export * from './directUrlHelpers.js';
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,uBAAuB,CAAA"}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var api_exports = {};
17
- module.exports = __toCommonJS(api_exports);
18
- __reExport(api_exports, require("./apiFunction.js"), module.exports);
19
- __reExport(api_exports, require("./scenario.js"), module.exports);
20
- __reExport(api_exports, require("./directive.js"), module.exports);
21
- __reExport(api_exports, require("./directUrlHelpers.js"), module.exports);
22
- // Annotate the CommonJS export names for ESM import in node:
23
- 0 && (module.exports = {
24
- ...require("./apiFunction.js"),
25
- ...require("./scenario.js"),
26
- ...require("./directive.js"),
27
- ...require("./directUrlHelpers.js")
28
- });
@@ -1,5 +0,0 @@
1
- export interface GlobalContext extends Record<string, unknown> {
2
- }
3
- export declare const context: {};
4
- export declare const setContext: (newContext: GlobalContext) => GlobalContext;
5
- //# sourceMappingURL=mockContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mockContext.d.ts","sourceRoot":"","sources":["../../../src/api/mockContext.ts"],"names":[],"mappings":"AAoCA,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEjE,eAAO,MAAM,OAAO,IAAc,CAAA;AAElC,eAAO,MAAM,UAAU,GAAI,YAAY,aAAa,KAAG,aAKtD,CAAA"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var mockContext_exports = {};
20
- __export(mockContext_exports, {
21
- context: () => context,
22
- setContext: () => setContext
23
- });
24
- module.exports = __toCommonJS(mockContext_exports);
25
- const mockContextStore = /* @__PURE__ */ new Map();
26
- const mockContext = new Proxy(
27
- {},
28
- {
29
- get: (_target, prop) => {
30
- if (prop === "toJSON") {
31
- return () => mockContextStore.get("context");
32
- }
33
- const ctx = mockContextStore.get("context");
34
- if (!ctx) {
35
- return void 0;
36
- }
37
- return ctx[prop];
38
- },
39
- set: (_target, prop, value) => {
40
- const ctx = mockContextStore.get("context");
41
- if (!ctx) {
42
- return false;
43
- }
44
- ctx[prop] = value;
45
- return true;
46
- }
47
- }
48
- );
49
- const context = mockContext;
50
- const setContext = (newContext) => {
51
- mockContextStore.set("context", newContext);
52
- return mockContext;
53
- };
54
- // Annotate the CommonJS export names for ESM import in node:
55
- 0 && (module.exports = {
56
- context,
57
- setContext
58
- });
@@ -1,108 +0,0 @@
1
- import type { A } from 'ts-toolbelt';
2
- /**
3
- * Use this function to define your scenario.
4
- *
5
- * @example
6
- * export const standard = defineScenario({
7
- * user: {
8
- * dom: {
9
- * name: 'Dom Saadi',
10
- * email: 'dom@cedarjs.com',
11
- * },
12
- * },
13
- * })
14
- *
15
- * @example
16
- * export const standard = defineScenario<Prisma.CreateUserArgs>({
17
- * user: {
18
- * dom: {
19
- * name: 'Dom Saadi',
20
- * email: 'dom@cedarjs.com',
21
- * },
22
- * },
23
- * })
24
- */
25
- export declare const defineScenario: DefineScenario;
26
- /**
27
- * @example
28
- * {
29
- * dannyUser: {
30
- * data: {
31
- * id: 1,
32
- * name: 'Danny',
33
- * },
34
- * },
35
- * }
36
- *
37
- * @example
38
- * krisUser: (scenario) => {
39
- * return {
40
- * data: {
41
- * id: 2,
42
- * name: 'Kris',
43
- * },
44
- * }
45
- * }
46
- */
47
- type ScenarioDefinitionMap<PrismaCreateType extends {
48
- data: any;
49
- }, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol> = Record<TKeys, A.Compute<PrismaCreateType> | ((scenario: Record<ModelName, Record<TKeys, any>>) => A.Compute<PrismaCreateType>)>;
50
- export interface DefineScenario {
51
- <PrismaCreateType extends {
52
- data: any;
53
- }, ModelName extends string | number | symbol = string | number | symbol, TKeys extends string | number | symbol = string | number | symbol>(scenarioMap: Record<ModelName, ScenarioDefinitionMap<PrismaCreateType, ModelName, TKeys>>): Record<ModelName, Record<TKeys, any>>;
54
- }
55
- /**
56
- * Type of data seeded by the scenario. Use this type to get the 'strict' return type of defineScenario
57
- *
58
- * @example
59
- * import { Product } from '@prisma/client'
60
- *
61
- * // If you scenario looks like this:
62
- * export const standard = defineScenario({
63
- * product: {
64
- * shirt: {
65
- * id: 55,
66
- * price: 10,
67
- * },
68
- * },
69
- * })
70
- *
71
- * // Export the StandardScenario type as
72
- * export StandardScenario = ScenarioData<Product, 'product'>
73
- *
74
- * // You can also define each of the keys in your scenario, so you get stricter type checking
75
- * export StandardScenario = ScenarioData<Product, 'product', 'shirt'>
76
- */
77
- export declare type ScenarioData<TModel, // the prisma model, imported from @prisma/client e.g. "Product"
78
- TName extends string | number = string | number, // (optional) name of the prisma model e.g. "product"
79
- TKeys extends string | number = string | number> = Record<TName, Record<TKeys, TModel>>;
80
- interface TestFunctionWithScenario<TData> {
81
- (scenario?: TData): Promise<void>;
82
- }
83
- interface DescribeBlockWithGetScenario<TData> {
84
- (getScenario: () => TData): void;
85
- }
86
- export interface Scenario {
87
- (title: string, testFunction: TestFunctionWithScenario<any>): void;
88
- }
89
- export interface Scenario {
90
- (namedScenario: string, title: string, testFunction: TestFunctionWithScenario<any>): void;
91
- }
92
- export interface Scenario {
93
- only: Scenario;
94
- }
95
- export interface DescribeScenario {
96
- <TData = any>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
97
- }
98
- export interface DescribeScenario {
99
- <TData>(title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
100
- }
101
- export interface DescribeScenario {
102
- <TData>(namedScenario: string, title: string, describeBlock: DescribeBlockWithGetScenario<TData>): void;
103
- }
104
- export interface DescribeScenario {
105
- only: DescribeScenario;
106
- }
107
- export {};
108
- //# sourceMappingURL=scenario.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scenario.d.ts","sourceRoot":"","sources":["../../../src/api/scenario.ts"],"names":[],"mappings":"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"}
@@ -1,30 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var scenario_exports = {};
20
- __export(scenario_exports, {
21
- defineScenario: () => defineScenario
22
- });
23
- module.exports = __toCommonJS(scenario_exports);
24
- const defineScenario = (data) => {
25
- return data;
26
- };
27
- // Annotate the CommonJS export names for ESM import in node:
28
- 0 && (module.exports = {
29
- defineScenario
30
- });
@@ -1,73 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var CedarApiVitestEnv_exports = {};
30
- __export(CedarApiVitestEnv_exports, {
31
- default: () => CedarApiVitestEnv_default
32
- });
33
- module.exports = __toCommonJS(CedarApiVitestEnv_exports);
34
- var import_internals = __toESM(require("@prisma/internals"), 1);
35
- var import_config = require("dotenv-defaults/config.js");
36
- var import_execa = __toESM(require("execa"), 1);
37
- var import_project_config = require("@cedarjs/project-config");
38
- var import_directUrlHelpers = require("../directUrlHelpers.js");
39
- const { getSchemaWithPath } = import_internals.default;
40
- const CedarApiVitestEnvironment = {
41
- name: "cedar-api",
42
- transformMode: "ssr",
43
- async setup() {
44
- if (process.env.SKIP_DB_PUSH === "1") {
45
- return {
46
- teardown() {
47
- }
48
- };
49
- }
50
- const cedarPaths = (0, import_project_config.getPaths)();
51
- const defaultDb = (0, import_directUrlHelpers.getDefaultDb)(cedarPaths.base);
52
- process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
53
- const schemaPath = await (0, import_project_config.getSchemaPath)(cedarPaths.api.prismaConfig);
54
- const result = await getSchemaWithPath(schemaPath);
55
- const prismaSchema = result.schemas.map(([, content]) => content).join("\n");
56
- const directUrlEnvVar = (0, import_directUrlHelpers.checkAndReplaceDirectUrl)(prismaSchema, defaultDb);
57
- const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force", "--skip-seed"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
58
- const directUrlDefinition = directUrlEnvVar ? { [directUrlEnvVar]: process.env[directUrlEnvVar] } : {};
59
- import_execa.default.sync("yarn", ["cedar", ...command], {
60
- cwd: cedarPaths.api.base,
61
- stdio: "inherit",
62
- env: {
63
- DATABASE_URL: process.env.DATABASE_URL,
64
- ...directUrlDefinition
65
- }
66
- });
67
- return {
68
- teardown() {
69
- }
70
- };
71
- }
72
- };
73
- var CedarApiVitestEnv_default = CedarApiVitestEnvironment;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var vitest_exports = {};
20
- __export(vitest_exports, {
21
- autoImportsPlugin: () => import_vite_plugin_auto_import.autoImportsPlugin,
22
- cedarVitestApiConfigPlugin: () => import_vite_plugin_cedar_vitest_api_config.cedarVitestApiConfigPlugin,
23
- trackDbImportsPlugin: () => import_vite_plugin_track_db_imports.trackDbImportsPlugin
24
- });
25
- module.exports = __toCommonJS(vitest_exports);
26
- var import_vite_plugin_auto_import = require("./vite-plugin-auto-import.js");
27
- var import_vite_plugin_cedar_vitest_api_config = require("./vite-plugin-cedar-vitest-api-config.js");
28
- var import_vite_plugin_track_db_imports = require("./vite-plugin-track-db-imports.js");
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
31
- autoImportsPlugin,
32
- cedarVitestApiConfigPlugin,
33
- trackDbImportsPlugin
34
- });
@@ -1,71 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var vite_plugin_auto_import_exports = {};
30
- __export(vite_plugin_auto_import_exports, {
31
- autoImportsPlugin: () => autoImportsPlugin
32
- });
33
- module.exports = __toCommonJS(vite_plugin_auto_import_exports);
34
- var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
35
- function autoImportsPlugin() {
36
- return (0, import_vite.default)({
37
- // targets to transform
38
- include: [
39
- /\.[tj]sx?$/
40
- // .ts, .tsx, .js, .jsx
41
- ],
42
- // global imports to register
43
- imports: [
44
- // import { mockContext, mockHttpEvent, mockSignedWebhook } from '@cedarjs/testing/api';
45
- {
46
- "@cedarjs/testing/api": [
47
- "mockContext",
48
- "mockHttpEvent",
49
- "mockSignedWebhook"
50
- ]
51
- },
52
- // import { gql } from 'graphql-tag'
53
- {
54
- "graphql-tag": ["gql"]
55
- },
56
- // import { context } from '@cedarjs/context'
57
- {
58
- "@cedarjs/context": ["context"]
59
- }
60
- ],
61
- // We provide our mocking types elsewhere and so don't need this plugin to
62
- // generate them.
63
- // TODO: Maybe we should have it at least generate the types for the gql
64
- // import? (Or do we already provide that some other way?)
65
- dts: false
66
- });
67
- }
68
- // Annotate the CommonJS export names for ESM import in node:
69
- 0 && (module.exports = {
70
- autoImportsPlugin
71
- });
@@ -1,69 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var vite_plugin_cedar_vitest_api_config_exports = {};
30
- __export(vite_plugin_cedar_vitest_api_config_exports, {
31
- cedarVitestApiConfigPlugin: () => cedarVitestApiConfigPlugin
32
- });
33
- module.exports = __toCommonJS(vite_plugin_cedar_vitest_api_config_exports);
34
- var import_node_path = __toESM(require("node:path"), 1);
35
- var import_project_config = require("@cedarjs/project-config");
36
- const import_meta = {};
37
- function cedarVitestApiConfigPlugin() {
38
- return {
39
- name: "cedar-vitest-plugin",
40
- config: () => {
41
- return {
42
- define: (0, import_project_config.getEnvVarDefinitions)(),
43
- ssr: {
44
- noExternal: ["@cedarjs/testing"]
45
- },
46
- resolve: {
47
- alias: {
48
- src: (0, import_project_config.getPaths)().api.src
49
- }
50
- },
51
- test: {
52
- environment: import_node_path.default.join(import_meta.dirname, "CedarApiVitestEnv.js"),
53
- // fileParallelism: false,
54
- // fileParallelism doesn't work with vitest projects (which is what
55
- // we're using in the root vitest.config.ts). As a workaround we set
56
- // poolOptions instead, which also shouldn't work, but was suggested
57
- // by Vitest team member AriPerkkio (Hiroshi's answer didn't work).
58
- // https://github.com/vitest-dev/vitest/discussions/7416
59
- poolOptions: { forks: { singleFork: true } },
60
- setupFiles: [import_node_path.default.join(import_meta.dirname, "vitest-api.setup.js")]
61
- }
62
- };
63
- }
64
- };
65
- }
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- cedarVitestApiConfigPlugin
69
- });