@cedarjs/testing 7.0.0-canary.2983 → 7.0.0-canary.2985

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 (142) hide show
  1. package/dist/cjs/web/MockRouter.d.ts.map +1 -1
  2. package/dist/cjs/web/mockRequests.js +2 -2
  3. package/dist/web/MockRouter.d.ts.map +1 -1
  4. package/package.json +12 -53
  5. package/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  6. package/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  7. package/config/jest/api/RedwoodApiJestEnv.js +0 -48
  8. package/config/jest/api/apiBabelConfig.d.ts +0 -5
  9. package/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  10. package/config/jest/api/apiBabelConfig.js +0 -34
  11. package/config/jest/api/globalSetup.d.ts +0 -3
  12. package/config/jest/api/globalSetup.d.ts.map +0 -1
  13. package/config/jest/api/globalSetup.js +0 -63
  14. package/config/jest/api/index.d.ts +0 -3
  15. package/config/jest/api/index.d.ts.map +0 -1
  16. package/config/jest/api/index.js +0 -25
  17. package/config/jest/api/jest-preset.d.ts +0 -4
  18. package/config/jest/api/jest-preset.d.ts.map +0 -1
  19. package/config/jest/api/jest-preset.js +0 -135
  20. package/config/jest/api/jest.setup.d.ts +0 -2
  21. package/config/jest/api/jest.setup.d.ts.map +0 -1
  22. package/config/jest/api/jest.setup.js +0 -267
  23. package/config/jest/api/package.json +0 -8
  24. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  25. package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  26. package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  27. package/config/jest/jest-serial-runner.d.ts +0 -8
  28. package/config/jest/jest-serial-runner.d.ts.map +0 -1
  29. package/config/jest/jest-serial-runner.js +0 -37
  30. package/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  31. package/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  32. package/config/jest/web/RedwoodWebJestEnv.js +0 -43
  33. package/config/jest/web/index.d.ts +0 -3
  34. package/config/jest/web/index.d.ts.map +0 -1
  35. package/config/jest/web/index.js +0 -25
  36. package/config/jest/web/jest-fixed-jsdom.d.js +0 -1
  37. package/config/jest/web/jest-preset.d.ts +0 -4
  38. package/config/jest/web/jest-preset.d.ts.map +0 -1
  39. package/config/jest/web/jest-preset.js +0 -224
  40. package/config/jest/web/jest.setup.d.ts +0 -7
  41. package/config/jest/web/jest.setup.d.ts.map +0 -1
  42. package/config/jest/web/jest.setup.js +0 -21
  43. package/config/jest/web/package.json +0 -8
  44. package/config/jest/web/resolver.d.ts +0 -4
  45. package/config/jest/web/resolver.d.ts.map +0 -1
  46. package/config/jest/web/resolver.js +0 -30
  47. package/config/jest/web/webBabelConfig.d.ts +0 -10
  48. package/config/jest/web/webBabelConfig.d.ts.map +0 -1
  49. package/config/jest/web/webBabelConfig.js +0 -48
  50. package/config/package.json +0 -1
  51. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  52. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  53. package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +0 -48
  54. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +0 -5
  55. package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  56. package/dist/cjs/config/jest/api/apiBabelConfig.js +0 -34
  57. package/dist/cjs/config/jest/api/globalSetup.d.ts +0 -3
  58. package/dist/cjs/config/jest/api/globalSetup.d.ts.map +0 -1
  59. package/dist/cjs/config/jest/api/globalSetup.js +0 -63
  60. package/dist/cjs/config/jest/api/index.d.ts +0 -3
  61. package/dist/cjs/config/jest/api/index.d.ts.map +0 -1
  62. package/dist/cjs/config/jest/api/index.js +0 -25
  63. package/dist/cjs/config/jest/api/jest-preset.d.ts +0 -4
  64. package/dist/cjs/config/jest/api/jest-preset.d.ts.map +0 -1
  65. package/dist/cjs/config/jest/api/jest-preset.js +0 -135
  66. package/dist/cjs/config/jest/api/jest.setup.d.ts +0 -2
  67. package/dist/cjs/config/jest/api/jest.setup.d.ts.map +0 -1
  68. package/dist/cjs/config/jest/api/jest.setup.js +0 -267
  69. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  70. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  71. package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -122
  72. package/dist/cjs/config/jest/jest-serial-runner.d.ts +0 -8
  73. package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +0 -1
  74. package/dist/cjs/config/jest/jest-serial-runner.js +0 -37
  75. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  76. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  77. package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +0 -43
  78. package/dist/cjs/config/jest/web/index.d.ts +0 -3
  79. package/dist/cjs/config/jest/web/index.d.ts.map +0 -1
  80. package/dist/cjs/config/jest/web/index.js +0 -25
  81. package/dist/cjs/config/jest/web/jest-fixed-jsdom.d.js +0 -1
  82. package/dist/cjs/config/jest/web/jest-preset.d.ts +0 -4
  83. package/dist/cjs/config/jest/web/jest-preset.d.ts.map +0 -1
  84. package/dist/cjs/config/jest/web/jest-preset.js +0 -224
  85. package/dist/cjs/config/jest/web/jest.setup.d.ts +0 -7
  86. package/dist/cjs/config/jest/web/jest.setup.d.ts.map +0 -1
  87. package/dist/cjs/config/jest/web/jest.setup.js +0 -21
  88. package/dist/cjs/config/jest/web/resolver.d.ts +0 -4
  89. package/dist/cjs/config/jest/web/resolver.d.ts.map +0 -1
  90. package/dist/cjs/config/jest/web/resolver.js +0 -30
  91. package/dist/cjs/config/jest/web/webBabelConfig.d.ts +0 -10
  92. package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +0 -1
  93. package/dist/cjs/config/jest/web/webBabelConfig.js +0 -48
  94. package/dist/cjs/web/fileMock.d.ts +0 -10
  95. package/dist/cjs/web/fileMock.d.ts.map +0 -1
  96. package/dist/cjs/web/fileMock.js +0 -24
  97. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +0 -11
  98. package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +0 -1
  99. package/dist/config/jest/api/RedwoodApiJestEnv.js +0 -28
  100. package/dist/config/jest/api/apiBabelConfig.d.ts +0 -5
  101. package/dist/config/jest/api/apiBabelConfig.d.ts.map +0 -1
  102. package/dist/config/jest/api/apiBabelConfig.js +0 -18
  103. package/dist/config/jest/api/globalSetup.d.ts +0 -3
  104. package/dist/config/jest/api/globalSetup.d.ts.map +0 -1
  105. package/dist/config/jest/api/globalSetup.js +0 -36
  106. package/dist/config/jest/api/index.d.ts +0 -3
  107. package/dist/config/jest/api/index.d.ts.map +0 -1
  108. package/dist/config/jest/api/index.js +0 -15
  109. package/dist/config/jest/api/jest-preset.d.ts +0 -4
  110. package/dist/config/jest/api/jest-preset.d.ts.map +0 -1
  111. package/dist/config/jest/api/jest-preset.js +0 -105
  112. package/dist/config/jest/api/jest.setup.d.ts +0 -2
  113. package/dist/config/jest/api/jest.setup.d.ts.map +0 -1
  114. package/dist/config/jest/api/jest.setup.js +0 -244
  115. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +0 -11
  116. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +0 -1
  117. package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +0 -102
  118. package/dist/config/jest/jest-serial-runner.d.ts +0 -8
  119. package/dist/config/jest/jest-serial-runner.d.ts.map +0 -1
  120. package/dist/config/jest/jest-serial-runner.js +0 -27
  121. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +0 -6
  122. package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +0 -1
  123. package/dist/config/jest/web/RedwoodWebJestEnv.js +0 -13
  124. package/dist/config/jest/web/index.d.ts +0 -3
  125. package/dist/config/jest/web/index.d.ts.map +0 -1
  126. package/dist/config/jest/web/index.js +0 -15
  127. package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -0
  128. package/dist/config/jest/web/jest-preset.d.ts +0 -4
  129. package/dist/config/jest/web/jest-preset.d.ts.map +0 -1
  130. package/dist/config/jest/web/jest-preset.js +0 -194
  131. package/dist/config/jest/web/jest.setup.d.ts +0 -7
  132. package/dist/config/jest/web/jest.setup.d.ts.map +0 -1
  133. package/dist/config/jest/web/jest.setup.js +0 -27
  134. package/dist/config/jest/web/resolver.d.ts +0 -4
  135. package/dist/config/jest/web/resolver.d.ts.map +0 -1
  136. package/dist/config/jest/web/resolver.js +0 -42
  137. package/dist/config/jest/web/webBabelConfig.d.ts +0 -10
  138. package/dist/config/jest/web/webBabelConfig.d.ts.map +0 -1
  139. package/dist/config/jest/web/webBabelConfig.js +0 -18
  140. package/dist/web/fileMock.d.ts +0 -10
  141. package/dist/web/fileMock.d.ts.map +0 -1
  142. 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("@cedarjs/testing/dist/cjs/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 } = require("@prisma/internals");
62
- const { getPrismaSchemas } = require("@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 } = require("@prisma/internals");
79
- const { getPrismaSchemas } = require("@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 } = require(`${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 = require(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,8 +0,0 @@
1
- {
2
- "name": "cedarjs-jest-api-preset",
3
- "version": "0.0.1",
4
- "type": "commonjs",
5
- "main": "index.js",
6
- "license": "MIT",
7
- "types": "./index.d.ts"
8
- }
@@ -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"}