@cedarjs/testing 6.0.2 → 6.0.3-next.227

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 (223) hide show
  1. package/dist/api/checkTestDatabase.d.ts +27 -0
  2. package/dist/api/checkTestDatabase.d.ts.map +1 -1
  3. package/dist/api/checkTestDatabase.js +102 -0
  4. package/dist/api/mockContext.d.ts +1 -1
  5. package/dist/api/mockContext.d.ts.map +1 -1
  6. package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
  7. package/dist/api/vitest/CedarApiVitestEnv.js +14 -2
  8. package/dist/api/vitest/teardown.d.ts +18 -0
  9. package/dist/api/vitest/teardown.d.ts.map +1 -0
  10. package/dist/api/vitest/teardown.js +43 -0
  11. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +1 -1
  12. package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +6 -1
  13. package/dist/api/vitest/vitest-api.setup.d.ts.map +1 -1
  14. package/dist/api/vitest/vitest-api.setup.js +9 -22
  15. package/dist/web/MockParamsProvider.d.ts.map +1 -1
  16. package/dist/web/MockParamsProvider.js +10 -1
  17. package/dist/web/MockRouter.d.ts.map +1 -1
  18. package/dist/web/mockRequests.d.ts +14 -0
  19. package/dist/web/mockRequests.d.ts.map +1 -1
  20. package/dist/web/mockRequests.js +8 -0
  21. package/package.json +22 -95
  22. package/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  23. package/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  24. package/config/jest/api/RedwoodApiJestEnv.js +0 -48
  25. package/config/jest/api/apiBabelConfig.d.ts +0 -5
  26. package/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  27. package/config/jest/api/apiBabelConfig.js +0 -34
  28. package/config/jest/api/globalSetup.d.ts +0 -3
  29. package/config/jest/api/globalSetup.d.ts.map +0 -1
  30. package/config/jest/api/globalSetup.js +0 -63
  31. package/config/jest/api/index.d.ts +0 -3
  32. package/config/jest/api/index.d.ts.map +0 -1
  33. package/config/jest/api/index.js +0 -25
  34. package/config/jest/api/jest-preset.d.ts +0 -4
  35. package/config/jest/api/jest-preset.d.ts.map +0 -1
  36. package/config/jest/api/jest-preset.js +0 -140
  37. package/config/jest/api/jest.setup.d.ts +0 -2
  38. package/config/jest/api/jest.setup.d.ts.map +0 -1
  39. package/config/jest/api/jest.setup.js +0 -267
  40. package/config/jest/api/package.json +0 -8
  41. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  42. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  43. package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  44. package/config/jest/jest-serial-runner.d.ts +0 -8
  45. package/config/jest/jest-serial-runner.d.ts.map +0 -1
  46. package/config/jest/jest-serial-runner.js +0 -37
  47. package/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  48. package/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  49. package/config/jest/web/RedwoodWebJestEnv.js +0 -43
  50. package/config/jest/web/index.d.ts +0 -3
  51. package/config/jest/web/index.d.ts.map +0 -1
  52. package/config/jest/web/index.js +0 -25
  53. package/config/jest/web/jest-fixed-jsdom.d.js +0 -1
  54. package/config/jest/web/jest-preset.d.ts +0 -4
  55. package/config/jest/web/jest-preset.d.ts.map +0 -1
  56. package/config/jest/web/jest-preset.js +0 -224
  57. package/config/jest/web/jest.setup.d.ts +0 -7
  58. package/config/jest/web/jest.setup.d.ts.map +0 -1
  59. package/config/jest/web/jest.setup.js +0 -21
  60. package/config/jest/web/package.json +0 -8
  61. package/config/jest/web/resolver.d.ts +0 -4
  62. package/config/jest/web/resolver.d.ts.map +0 -1
  63. package/config/jest/web/resolver.js +0 -30
  64. package/config/jest/web/webBabelConfig.d.ts +0 -10
  65. package/config/jest/web/webBabelConfig.d.ts.map +0 -1
  66. package/config/jest/web/webBabelConfig.js +0 -48
  67. package/config/package.json +0 -1
  68. package/dist/cjs/api/apiFunction.d.ts +0 -37
  69. package/dist/cjs/api/apiFunction.d.ts.map +0 -1
  70. package/dist/cjs/api/apiFunction.js +0 -89
  71. package/dist/cjs/api/checkTestDatabase.d.ts +0 -23
  72. package/dist/cjs/api/checkTestDatabase.d.ts.map +0 -1
  73. package/dist/cjs/api/checkTestDatabase.js +0 -69
  74. package/dist/cjs/api/directive.d.ts +0 -51
  75. package/dist/cjs/api/directive.d.ts.map +0 -1
  76. package/dist/cjs/api/directive.js +0 -77
  77. package/dist/cjs/api/index.d.ts +0 -4
  78. package/dist/cjs/api/index.d.ts.map +0 -1
  79. package/dist/cjs/api/index.js +0 -26
  80. package/dist/cjs/api/mockContext.d.ts +0 -5
  81. package/dist/cjs/api/mockContext.d.ts.map +0 -1
  82. package/dist/cjs/api/mockContext.js +0 -58
  83. package/dist/cjs/api/scenario.d.ts +0 -108
  84. package/dist/cjs/api/scenario.d.ts.map +0 -1
  85. package/dist/cjs/api/scenario.js +0 -30
  86. package/dist/cjs/api/vitest/CedarApiVitestEnv.js +0 -75
  87. package/dist/cjs/api/vitest/index.js +0 -34
  88. package/dist/cjs/api/vitest/vite-plugin-auto-import.js +0 -71
  89. package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +0 -69
  90. package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +0 -47
  91. package/dist/cjs/api/vitest/vitest-api.setup.js +0 -270
  92. package/dist/cjs/cache/index.d.ts +0 -50
  93. package/dist/cjs/cache/index.d.ts.map +0 -1
  94. package/dist/cjs/cache/index.js +0 -104
  95. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  96. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  97. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +0 -48
  98. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +0 -5
  99. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  100. package/dist/cjs/config/jest/api/apiBabelConfig.js +0 -34
  101. package/dist/cjs/config/jest/api/globalSetup.d.ts +0 -3
  102. package/dist/cjs/config/jest/api/globalSetup.d.ts.map +0 -1
  103. package/dist/cjs/config/jest/api/globalSetup.js +0 -63
  104. package/dist/cjs/config/jest/api/index.d.ts +0 -3
  105. package/dist/cjs/config/jest/api/index.d.ts.map +0 -1
  106. package/dist/cjs/config/jest/api/index.js +0 -25
  107. package/dist/cjs/config/jest/api/jest-preset.d.ts +0 -4
  108. package/dist/cjs/config/jest/api/jest-preset.d.ts.map +0 -1
  109. package/dist/cjs/config/jest/api/jest-preset.js +0 -140
  110. package/dist/cjs/config/jest/api/jest.setup.d.ts +0 -2
  111. package/dist/cjs/config/jest/api/jest.setup.d.ts.map +0 -1
  112. package/dist/cjs/config/jest/api/jest.setup.js +0 -267
  113. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  114. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  115. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  116. package/dist/cjs/config/jest/jest-serial-runner.d.ts +0 -8
  117. package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +0 -1
  118. package/dist/cjs/config/jest/jest-serial-runner.js +0 -37
  119. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  120. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  121. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +0 -43
  122. package/dist/cjs/config/jest/web/index.d.ts +0 -3
  123. package/dist/cjs/config/jest/web/index.d.ts.map +0 -1
  124. package/dist/cjs/config/jest/web/index.js +0 -25
  125. package/dist/cjs/config/jest/web/jest-fixed-jsdom.d.js +0 -1
  126. package/dist/cjs/config/jest/web/jest-preset.d.ts +0 -4
  127. package/dist/cjs/config/jest/web/jest-preset.d.ts.map +0 -1
  128. package/dist/cjs/config/jest/web/jest-preset.js +0 -224
  129. package/dist/cjs/config/jest/web/jest.setup.d.ts +0 -7
  130. package/dist/cjs/config/jest/web/jest.setup.d.ts.map +0 -1
  131. package/dist/cjs/config/jest/web/jest.setup.js +0 -21
  132. package/dist/cjs/config/jest/web/resolver.d.ts +0 -4
  133. package/dist/cjs/config/jest/web/resolver.d.ts.map +0 -1
  134. package/dist/cjs/config/jest/web/resolver.js +0 -30
  135. package/dist/cjs/config/jest/web/webBabelConfig.d.ts +0 -10
  136. package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +0 -1
  137. package/dist/cjs/config/jest/web/webBabelConfig.js +0 -48
  138. package/dist/cjs/package.json +0 -1
  139. package/dist/cjs/web/MockParamsProvider.d.ts +0 -7
  140. package/dist/cjs/web/MockParamsProvider.d.ts.map +0 -1
  141. package/dist/cjs/web/MockParamsProvider.js +0 -44
  142. package/dist/cjs/web/MockProviders.d.ts +0 -5
  143. package/dist/cjs/web/MockProviders.d.ts.map +0 -1
  144. package/dist/cjs/web/MockProviders.js +0 -66
  145. package/dist/cjs/web/MockRouter.d.ts +0 -11
  146. package/dist/cjs/web/MockRouter.d.ts.map +0 -1
  147. package/dist/cjs/web/MockRouter.js +0 -48
  148. package/dist/cjs/web/customRender.d.ts +0 -6
  149. package/dist/cjs/web/customRender.d.ts.map +0 -1
  150. package/dist/cjs/web/customRender.js +0 -54
  151. package/dist/cjs/web/fileMock.d.ts +0 -10
  152. package/dist/cjs/web/fileMock.d.ts.map +0 -1
  153. package/dist/cjs/web/fileMock.js +0 -24
  154. package/dist/cjs/web/findCellMocks.d.ts +0 -2
  155. package/dist/cjs/web/findCellMocks.d.ts.map +0 -1
  156. package/dist/cjs/web/findCellMocks.js +0 -45
  157. package/dist/cjs/web/globRoutesImporter.d.ts +0 -13
  158. package/dist/cjs/web/globRoutesImporter.d.ts.map +0 -1
  159. package/dist/cjs/web/globRoutesImporter.js +0 -46
  160. package/dist/cjs/web/global.d.ts +0 -6
  161. package/dist/cjs/web/global.d.ts.map +0 -1
  162. package/dist/cjs/web/global.js +0 -1
  163. package/dist/cjs/web/index.d.ts +0 -6
  164. package/dist/cjs/web/index.d.ts.map +0 -1
  165. package/dist/cjs/web/index.js +0 -41
  166. package/dist/cjs/web/mockAuth.d.ts +0 -29
  167. package/dist/cjs/web/mockAuth.d.ts.map +0 -1
  168. package/dist/cjs/web/mockAuth.js +0 -89
  169. package/dist/cjs/web/mockRequests.d.ts +0 -72
  170. package/dist/cjs/web/mockRequests.d.ts.map +0 -1
  171. package/dist/cjs/web/mockRequests.js +0 -210
  172. package/dist/cjs/web/vitest/index.js +0 -37
  173. package/dist/cjs/web/vitest/vite-plugin-auto-import.js +0 -60
  174. package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +0 -51
  175. package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +0 -42
  176. package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +0 -43
  177. package/dist/cjs/web/vitest/vitest-web.setup.js +0 -19
  178. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  179. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  180. package/dist/config/jest/api/RedwoodApiJestEnv.js +0 -28
  181. package/dist/config/jest/api/apiBabelConfig.d.ts +0 -5
  182. package/dist/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  183. package/dist/config/jest/api/apiBabelConfig.js +0 -18
  184. package/dist/config/jest/api/globalSetup.d.ts +0 -3
  185. package/dist/config/jest/api/globalSetup.d.ts.map +0 -1
  186. package/dist/config/jest/api/globalSetup.js +0 -36
  187. package/dist/config/jest/api/index.d.ts +0 -3
  188. package/dist/config/jest/api/index.d.ts.map +0 -1
  189. package/dist/config/jest/api/index.js +0 -15
  190. package/dist/config/jest/api/jest-preset.d.ts +0 -4
  191. package/dist/config/jest/api/jest-preset.d.ts.map +0 -1
  192. package/dist/config/jest/api/jest-preset.js +0 -110
  193. package/dist/config/jest/api/jest.setup.d.ts +0 -2
  194. package/dist/config/jest/api/jest.setup.d.ts.map +0 -1
  195. package/dist/config/jest/api/jest.setup.js +0 -244
  196. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  197. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  198. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -102
  199. package/dist/config/jest/jest-serial-runner.d.ts +0 -8
  200. package/dist/config/jest/jest-serial-runner.d.ts.map +0 -1
  201. package/dist/config/jest/jest-serial-runner.js +0 -27
  202. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  203. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  204. package/dist/config/jest/web/RedwoodWebJestEnv.js +0 -13
  205. package/dist/config/jest/web/index.d.ts +0 -3
  206. package/dist/config/jest/web/index.d.ts.map +0 -1
  207. package/dist/config/jest/web/index.js +0 -15
  208. package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -0
  209. package/dist/config/jest/web/jest-preset.d.ts +0 -4
  210. package/dist/config/jest/web/jest-preset.d.ts.map +0 -1
  211. package/dist/config/jest/web/jest-preset.js +0 -194
  212. package/dist/config/jest/web/jest.setup.d.ts +0 -7
  213. package/dist/config/jest/web/jest.setup.d.ts.map +0 -1
  214. package/dist/config/jest/web/jest.setup.js +0 -27
  215. package/dist/config/jest/web/resolver.d.ts +0 -4
  216. package/dist/config/jest/web/resolver.d.ts.map +0 -1
  217. package/dist/config/jest/web/resolver.js +0 -42
  218. package/dist/config/jest/web/webBabelConfig.d.ts +0 -10
  219. package/dist/config/jest/web/webBabelConfig.d.ts.map +0 -1
  220. package/dist/config/jest/web/webBabelConfig.js +0 -18
  221. package/dist/web/fileMock.d.ts +0 -10
  222. package/dist/web/fileMock.d.ts.map +0 -1
  223. package/dist/web/fileMock.js +0 -4
@@ -1,267 +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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_node_fs = __toESM(require("node:fs"), 1);
25
- var import_node_path = __toESM(require("node:path"), 1);
26
- var import_scenario = require("../../../api/scenario.js");
27
- const { apiSrcPath, tearDownCachePath } = global.__CEDARJS__TEST_IMPORTS;
28
- global.defineScenario = import_scenario.defineScenario;
29
- const mockContextStore = /* @__PURE__ */ new Map();
30
- const mockContext = new Proxy(
31
- {},
32
- {
33
- get: (_target, prop) => {
34
- if (prop === "toJSON") {
35
- return () => mockContextStore.get("context");
36
- }
37
- return mockContextStore.get("context")[prop];
38
- },
39
- set: (_target, prop, value) => {
40
- const ctx = mockContextStore.get("context");
41
- ctx[prop] = value;
42
- return true;
43
- }
44
- }
45
- );
46
- global.mockCurrentUser = (currentUser) => {
47
- mockContextStore.set("context", { currentUser });
48
- };
49
- const HANDLED_ERRORS = [1451, 1811, 23001, 23503];
50
- const TEARDOWN_CACHE_PATH = tearDownCachePath;
51
- const DEFAULT_SCENARIO = "standard";
52
- let teardownOrder = [];
53
- let originalTeardownOrder = [];
54
- const deepCopy = (obj) => {
55
- return JSON.parse(JSON.stringify(obj));
56
- };
57
- const isIdenticalArray = (a, b) => {
58
- return JSON.stringify(a) === JSON.stringify(b);
59
- };
60
- const configureTeardown = async () => {
61
- const { getDMMF } = await import("@prisma/internals");
62
- const { getPrismaSchemas } = await import("@cedarjs/project-config");
63
- const { schemas } = await getPrismaSchemas();
64
- const schema = await getDMMF({ datamodel: schemas });
65
- const schemaModels = schema.datamodel.models.map(
66
- (m) => m.dbName || m.name
67
- );
68
- if (import_node_fs.default.existsSync(TEARDOWN_CACHE_PATH)) {
69
- teardownOrder = JSON.parse(import_node_fs.default.readFileSync(TEARDOWN_CACHE_PATH).toString());
70
- }
71
- if (teardownOrder.length !== schemaModels.length) {
72
- teardownOrder = schemaModels;
73
- }
74
- originalTeardownOrder = deepCopy(teardownOrder);
75
- };
76
- let quoteStyle;
77
- const getQuoteStyle = async () => {
78
- const { getConfig: getPrismaConfig } = await import("@prisma/internals");
79
- const { getPrismaSchemas } = await import("@cedarjs/project-config");
80
- const result = await getPrismaSchemas();
81
- if (!quoteStyle) {
82
- const config = await getPrismaConfig({ datamodel: result.schemas });
83
- switch (config.datasources?.[0]?.provider) {
84
- case "mysql":
85
- quoteStyle = "`";
86
- break;
87
- default:
88
- quoteStyle = '"';
89
- }
90
- }
91
- return quoteStyle;
92
- };
93
- const getProjectDb = async () => {
94
- const { db } = await import(`${apiSrcPath}/lib/db`);
95
- return db;
96
- };
97
- function buildScenario(itFunc, testPath) {
98
- const scenarioFunc = (...args) => {
99
- let scenarioName, testName, testFunc;
100
- if (args.length === 3) {
101
- ;
102
- [scenarioName, testName, testFunc] = args;
103
- } else if (args.length === 2) {
104
- scenarioName = DEFAULT_SCENARIO;
105
- [testName, testFunc] = args;
106
- } else {
107
- throw new Error("scenario() requires 2 or 3 arguments");
108
- }
109
- return itFunc(testName, async () => {
110
- const { scenario } = await loadScenarios(testPath, scenarioName);
111
- const scenarioData = await seedScenario(scenario);
112
- try {
113
- const result = await testFunc(scenarioData);
114
- return result;
115
- } finally {
116
- if (wasDbUsed()) {
117
- await teardown();
118
- }
119
- }
120
- });
121
- };
122
- return Object.assign(scenarioFunc, { only: scenarioFunc });
123
- }
124
- function buildDescribeScenario(describeFunc, testPath) {
125
- const describeScenarioFunc = (...args) => {
126
- let scenarioName, describeBlockName, describeBlock;
127
- if (args.length === 3) {
128
- ;
129
- [scenarioName, describeBlockName, describeBlock] = args;
130
- } else if (args.length === 2) {
131
- scenarioName = DEFAULT_SCENARIO;
132
- [describeBlockName, describeBlock] = args;
133
- } else {
134
- throw new Error("describeScenario() requires 2 or 3 arguments");
135
- }
136
- return describeFunc(describeBlockName, () => {
137
- let scenarioData;
138
- beforeAll(async () => {
139
- const { scenario } = await loadScenarios(testPath, scenarioName);
140
- scenarioData = await seedScenario(scenario);
141
- });
142
- afterAll(async () => {
143
- if (wasDbUsed()) {
144
- await teardown();
145
- }
146
- });
147
- const getScenario = () => scenarioData;
148
- describeBlock(getScenario);
149
- });
150
- };
151
- return Object.assign(describeScenarioFunc, { only: describeScenarioFunc });
152
- }
153
- const teardown = async () => {
154
- const quoteStyle2 = await getQuoteStyle();
155
- for (let i = 0; i < teardownOrder.length; i++) {
156
- const modelName = teardownOrder[i];
157
- if (!modelName) {
158
- continue;
159
- }
160
- try {
161
- const db = await getProjectDb();
162
- await db.$executeRawUnsafe(
163
- `DELETE FROM ${quoteStyle2}${modelName}${quoteStyle2}`
164
- );
165
- } catch (e) {
166
- const message = isErrorWithMessage(e) ? e.message : "";
167
- const match = message.match(/Code: `(\d+)`/);
168
- if (match && HANDLED_ERRORS.includes(parseInt(match[1]))) {
169
- teardownOrder.splice(i, 1);
170
- teardownOrder.push(modelName);
171
- i--;
172
- } else {
173
- throw e;
174
- }
175
- }
176
- }
177
- if (!isIdenticalArray(teardownOrder, originalTeardownOrder)) {
178
- originalTeardownOrder = deepCopy(teardownOrder);
179
- import_node_fs.default.writeFileSync(TEARDOWN_CACHE_PATH, JSON.stringify(teardownOrder));
180
- }
181
- };
182
- const seedScenario = async (scenario) => {
183
- if (scenario) {
184
- const scenarios = {};
185
- const db = await getProjectDb();
186
- for (const [model, namedFixtures] of Object.entries(scenario)) {
187
- scenarios[model] = {};
188
- for (const [name, createArgs] of Object.entries(namedFixtures)) {
189
- if (typeof createArgs === "function") {
190
- scenarios[model][name] = await db[model].create(createArgs(scenarios));
191
- } else {
192
- scenarios[model][name] = await db[model].create(createArgs);
193
- }
194
- }
195
- }
196
- return scenarios;
197
- } else {
198
- return {};
199
- }
200
- };
201
- global.scenario = buildScenario(global.it, global.testPath);
202
- global.describeScenario = buildDescribeScenario(
203
- global.describe,
204
- global.testPath
205
- );
206
- const wasDbUsed = () => {
207
- try {
208
- const libDbPath = require.resolve(`${apiSrcPath}/lib/db`);
209
- return Object.keys(require.cache).some((module2) => {
210
- return module2 === libDbPath;
211
- });
212
- } catch {
213
- return false;
214
- }
215
- };
216
- jest.mock("@cedarjs/context", () => {
217
- return {
218
- context: mockContext,
219
- setContext: (newContext) => {
220
- mockContextStore.set("context", newContext);
221
- }
222
- };
223
- });
224
- beforeEach(() => {
225
- mockContextStore.set("context", {});
226
- });
227
- beforeAll(async () => {
228
- if (wasDbUsed()) {
229
- await configureTeardown();
230
- }
231
- });
232
- afterAll(async () => {
233
- if (wasDbUsed()) {
234
- const db = await getProjectDb();
235
- db.$disconnect();
236
- }
237
- });
238
- async function loadScenarios(testPath, scenarioName) {
239
- const testFileDir = import_node_path.default.parse(testPath);
240
- const testFileNameParts = testFileDir.name.split(".");
241
- const testFilePath = `${testFileDir.dir}/${testFileNameParts.slice(0, testFileNameParts.length - 1).join(".")}.scenarios`;
242
- let allScenarios;
243
- let scenario;
244
- try {
245
- allScenarios = await import(testFilePath);
246
- } catch (e) {
247
- if (isErrorWithCode(e) && e.code !== "MODULE_NOT_FOUND") {
248
- throw new Error(`Failed to load scenario: ${e}`);
249
- }
250
- }
251
- if (allScenarios) {
252
- if (allScenarios[scenarioName]) {
253
- scenario = allScenarios[scenarioName];
254
- } else {
255
- throw new Error(
256
- `UndefinedScenario: There is no scenario named "${scenarioName}" in ${testFilePath}.{js,ts}`
257
- );
258
- }
259
- }
260
- return { scenario };
261
- }
262
- function isErrorWithCode(error) {
263
- return !!error && typeof error === "object" && "code" in error && typeof error.code === "string";
264
- }
265
- function isErrorWithMessage(error) {
266
- return !!error && typeof error === "object" && "message" in error && typeof error.message === "string";
267
- }
@@ -1,11 +0,0 @@
1
- import type { PluginObj, PluginPass } from '@babel/core';
2
- import type * as t from '@babel/types';
3
- interface PluginState extends PluginPass {
4
- exportNames: string[];
5
- hasDefaultExport: boolean;
6
- }
7
- export default function ({ types, }: {
8
- types: typeof t;
9
- }): PluginObj<PluginState>;
10
- export {};
11
- //# sourceMappingURL=babel-plugin-redwood-cell.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"babel-plugin-redwood-cell.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/babelPlugins/babel-plugin-redwood-cell.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAA;AAsCtC,UAAU,WAAY,SAAQ,UAAU;IAKtC,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,CAAC,OAAO,WAAW,EACvB,KAAK,GACN,EAAE;IACD,KAAK,EAAE,OAAO,CAAC,CAAA;CAChB,GAAG,SAAS,CAAC,WAAW,CAAC,CAoHzB"}
@@ -1,122 +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 babel_plugin_redwood_cell_exports = {};
20
- __export(babel_plugin_redwood_cell_exports, {
21
- default: () => babel_plugin_redwood_cell_default
22
- });
23
- module.exports = __toCommonJS(babel_plugin_redwood_cell_exports);
24
- var import_node_path = require("node:path");
25
- const EXPECTED_EXPORTS_FROM_CELL = [
26
- "beforeQuery",
27
- "QUERY",
28
- "FRAGMENT",
29
- "data",
30
- "isEmpty",
31
- "afterQuery",
32
- "Loading",
33
- "Success",
34
- "Failure",
35
- "Empty"
36
- ];
37
- function isExpectedExport(name) {
38
- return name !== void 0 && EXPECTED_EXPORTS_FROM_CELL.includes(name);
39
- }
40
- function babel_plugin_redwood_cell_default({
41
- types
42
- }) {
43
- return {
44
- name: "babel-plugin-redwood-cell",
45
- visitor: {
46
- ExportDefaultDeclaration(path, state) {
47
- state.hasDefaultExport = true;
48
- },
49
- ExportNamedDeclaration(path, state) {
50
- const declaration = path.node.declaration;
51
- if (!declaration) {
52
- return;
53
- }
54
- let name;
55
- if (declaration.type === "VariableDeclaration") {
56
- const id = declaration.declarations[0].id;
57
- if (id.type === "Identifier") {
58
- name = id.name;
59
- }
60
- }
61
- if (declaration.type === "FunctionDeclaration") {
62
- name = declaration?.id?.name;
63
- }
64
- if (isExpectedExport(name)) {
65
- state.exportNames.push(name);
66
- }
67
- },
68
- Program: {
69
- enter(_path, state) {
70
- state.exportNames = [];
71
- state.hasDefaultExport = false;
72
- },
73
- exit(path, state) {
74
- const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("FRAGMENT") || state.exportNames.includes("data");
75
- if (state.hasDefaultExport || !hasQueryOrDataExport) {
76
- return;
77
- }
78
- const createCellHookName = state.exportNames.includes("data") ? "createServerCell" : "createCell";
79
- const importFrom = state.exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
80
- path.node.body.unshift(
81
- types.importDeclaration(
82
- [
83
- types.importSpecifier(
84
- types.identifier(createCellHookName),
85
- types.identifier(createCellHookName)
86
- )
87
- ],
88
- types.stringLiteral(importFrom)
89
- )
90
- );
91
- const objectProperties = [
92
- ...state.exportNames.map(
93
- (name) => types.objectProperty(
94
- types.identifier(name),
95
- types.identifier(name),
96
- false,
97
- true
98
- )
99
- )
100
- ];
101
- if (state.file.opts.filename) {
102
- objectProperties.push(
103
- types.objectProperty(
104
- types.identifier("displayName"),
105
- types.stringLiteral((0, import_node_path.parse)(state.file.opts.filename).name),
106
- false,
107
- true
108
- )
109
- );
110
- }
111
- path.node.body.push(
112
- types.exportDefaultDeclaration(
113
- types.callExpression(types.identifier(createCellHookName), [
114
- types.objectExpression(objectProperties)
115
- ])
116
- )
117
- );
118
- }
119
- }
120
- }
121
- };
122
- }
@@ -1,8 +0,0 @@
1
- import jestRunner from 'jest-runner';
2
- declare const TestRunner: (typeof jestRunner)['default'];
3
- declare class SerialRunner extends TestRunner {
4
- isSerial: boolean;
5
- constructor(...attr: ConstructorParameters<typeof TestRunner>);
6
- }
7
- export = SerialRunner;
8
- //# sourceMappingURL=jest-serial-runner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest-serial-runner.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/jest-serial-runner.ts"],"names":[],"mappings":"AAGA,OAAO,UAAU,MAAM,aAAa,CAAA;AAGpC,QAAA,MAAM,UAAU,EAAE,CAAC,OAAO,UAAU,CAAC,CAAC,SAAS,CAGb,CAAA;AAElC,cAAM,YAAa,SAAQ,UAAU;IAC5B,QAAQ,EAAE,OAAO,CAAA;gBAEZ,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,UAAU,CAAC;CAI9D;AAMD,SAAS,YAAY,CAAA"}
@@ -1,37 +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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var import_jest_runner = __toESM(require("jest-runner"), 1);
25
- const TestRunner = (
26
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
27
- // @ts-ignore
28
- import_jest_runner.default.default || import_jest_runner.default
29
- );
30
- class SerialRunner extends TestRunner {
31
- isSerial;
32
- constructor(...attr) {
33
- super(...attr);
34
- this.isSerial = true;
35
- }
36
- }
37
- module.exports = SerialRunner;
@@ -1,6 +0,0 @@
1
- import JSDOMEnvironment from 'jest-fixed-jsdom';
2
- declare class RedwoodWebJestEnvironment extends JSDOMEnvironment {
3
- setup(): Promise<void>;
4
- }
5
- export default RedwoodWebJestEnvironment;
6
- //# sourceMappingURL=RedwoodWebJestEnv.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RedwoodWebJestEnv.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/web/RedwoodWebJestEnv.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,kBAAkB,CAAA;AAkB/C,cAAM,yBAA0B,SAAQ,gBAAgB;IAChD,KAAK;CASZ;AAED,eAAe,yBAAyB,CAAA"}
@@ -1,43 +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 RedwoodWebJestEnv_exports = {};
30
- __export(RedwoodWebJestEnv_exports, {
31
- default: () => RedwoodWebJestEnv_default
32
- });
33
- module.exports = __toCommonJS(RedwoodWebJestEnv_exports);
34
- var import_jest_fixed_jsdom = __toESM(require("jest-fixed-jsdom"), 1);
35
- class RedwoodWebJestEnvironment extends import_jest_fixed_jsdom.default {
36
- async setup() {
37
- await super.setup();
38
- if (typeof this.global.crypto.subtle === "undefined") {
39
- this.global.crypto.subtle = {};
40
- }
41
- }
42
- }
43
- var RedwoodWebJestEnv_default = RedwoodWebJestEnvironment;
@@ -1,3 +0,0 @@
1
- import * as jestPreset from './jest-preset.js';
2
- export = jestPreset;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/web/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAM9C,SAAS,UAAU,CAAA"}
@@ -1,25 +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 __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (let key of __getOwnPropNames(from))
11
- if (!__hasOwnProp.call(to, key) && key !== except)
12
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- }
14
- return to;
15
- };
16
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
- // If the importer is in node compatibility mode or this is not an ESM
18
- // file that has been converted to a CommonJS file using a Babel-
19
- // compatible transform (i.e. "__esModule" has not been set), then set
20
- // "default" to the CommonJS "module.exports" for node compatibility.
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var jestPreset = __toESM(require("./jest-preset.js"), 1);
25
- module.exports = jestPreset;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,4 +0,0 @@
1
- import type { Config } from 'jest';
2
- declare const config: Config;
3
- export default config;
4
- //# sourceMappingURL=jest-preset.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/web/jest-preset.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiIlC,QAAA,MAAM,MAAM,EAAE,MA0Ib,CAAA;AAED,eAAe,MAAM,CAAA"}