@cedarjs/testing 0.6.1-next.0 → 0.6.1-next.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/config/jest/api/RedwoodApiJestEnv.js +33 -16
- package/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/config/jest/api/apiBabelConfig.js +33 -17
- package/config/jest/api/globalSetup.d.ts +3 -0
- package/config/jest/api/globalSetup.d.ts.map +1 -0
- package/config/jest/api/globalSetup.js +59 -44
- package/config/jest/api/index.d.ts +3 -0
- package/config/jest/api/index.d.ts.map +1 -0
- package/config/jest/api/index.js +25 -2
- package/config/jest/api/jest-preset.d.ts +4 -0
- package/config/jest/api/jest-preset.d.ts.map +1 -0
- package/config/jest/api/jest-preset.js +69 -39
- package/config/jest/api/jest.setup.d.ts +2 -0
- package/config/jest/api/jest.setup.d.ts.map +1 -0
- package/config/jest/api/jest.setup.js +189 -248
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +103 -124
- package/config/jest/jest-serial-runner.d.ts +8 -0
- package/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/config/jest/jest-serial-runner.js +33 -9
- package/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/config/jest/web/RedwoodWebJestEnv.js +33 -12
- package/config/jest/web/index.d.ts +3 -0
- package/config/jest/web/index.d.ts.map +1 -0
- package/config/jest/web/index.js +25 -2
- package/config/jest/web/jest-preset.d.ts +4 -0
- package/config/jest/web/jest-preset.d.ts.map +1 -0
- package/config/jest/web/jest-preset.js +78 -50
- package/config/jest/web/jest.setup.d.ts +8 -0
- package/config/jest/web/jest.setup.d.ts.map +1 -0
- package/config/jest/web/jest.setup.js +17 -36
- package/config/jest/web/resolver.d.ts +4 -0
- package/config/jest/web/resolver.d.ts.map +1 -0
- package/config/jest/web/resolver.js +24 -31
- package/config/jest/web/webBabelConfig.d.ts +10 -0
- package/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/config/jest/web/webBabelConfig.js +43 -13
- package/config/package.json +1 -0
- package/dist/api/directUrlHelpers.d.ts.map +1 -1
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +1 -0
- package/dist/cjs/api/directUrlHelpers.d.ts.map +1 -1
- package/dist/cjs/api/index.d.ts +1 -0
- package/dist/cjs/api/index.d.ts.map +1 -1
- package/dist/cjs/api/index.js +3 -1
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/RedwoodApiJestEnv.js +48 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/apiBabelConfig.js +34 -0
- package/dist/cjs/config/jest/api/globalSetup.d.ts +3 -0
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/globalSetup.js +61 -0
- package/dist/cjs/config/jest/api/index.d.ts +3 -0
- package/dist/cjs/config/jest/api/index.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/index.js +25 -0
- package/dist/cjs/config/jest/api/jest-preset.d.ts +4 -0
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/jest-preset.js +97 -0
- package/dist/cjs/config/jest/api/jest.setup.d.ts +2 -0
- package/dist/cjs/config/jest/api/jest.setup.d.ts.map +1 -0
- package/dist/cjs/config/jest/api/jest.setup.js +267 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +121 -0
- package/dist/cjs/config/jest/jest-serial-runner.d.ts +8 -0
- package/dist/cjs/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/dist/cjs/config/jest/jest-serial-runner.js +37 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +38 -0
- package/dist/cjs/config/jest/web/index.d.ts +3 -0
- package/dist/cjs/config/jest/web/index.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/index.js +25 -0
- package/dist/cjs/config/jest/web/jest-preset.d.ts +4 -0
- package/dist/cjs/config/jest/web/jest-preset.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/jest-preset.js +117 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts +8 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/jest.setup.js +22 -0
- package/dist/cjs/config/jest/web/resolver.d.ts +4 -0
- package/dist/cjs/config/jest/web/resolver.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/resolver.js +30 -0
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts +10 -0
- package/dist/cjs/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/webBabelConfig.js +48 -0
- package/dist/cjs/web/global.d.ts +2 -2
- package/dist/cjs/web/global.d.ts.map +1 -1
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts +11 -0
- package/dist/config/jest/api/RedwoodApiJestEnv.d.ts.map +1 -0
- package/dist/config/jest/api/RedwoodApiJestEnv.js +28 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts +5 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts.map +1 -0
- package/dist/config/jest/api/apiBabelConfig.js +18 -0
- package/dist/config/jest/api/globalSetup.d.ts +3 -0
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -0
- package/dist/config/jest/api/globalSetup.js +34 -0
- package/dist/config/jest/api/index.d.ts +3 -0
- package/dist/config/jest/api/index.d.ts.map +1 -0
- package/dist/config/jest/api/index.js +11 -0
- package/dist/config/jest/api/jest-preset.d.ts +4 -0
- package/dist/config/jest/api/jest-preset.d.ts.map +1 -0
- package/dist/config/jest/api/jest-preset.js +67 -0
- package/dist/config/jest/api/jest.setup.d.ts +2 -0
- package/dist/config/jest/api/jest.setup.d.ts.map +1 -0
- package/dist/config/jest/api/jest.setup.js +244 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts +11 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -0
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +101 -0
- package/dist/config/jest/jest-serial-runner.d.ts +8 -0
- package/dist/config/jest/jest-serial-runner.d.ts.map +1 -0
- package/dist/config/jest/jest-serial-runner.js +23 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +6 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -0
- package/dist/config/jest/web/RedwoodWebJestEnv.js +18 -0
- package/dist/config/jest/web/index.d.ts +3 -0
- package/dist/config/jest/web/index.d.ts.map +1 -0
- package/dist/config/jest/web/index.js +11 -0
- package/dist/config/jest/web/jest-preset.d.ts +4 -0
- package/dist/config/jest/web/jest-preset.d.ts.map +1 -0
- package/dist/config/jest/web/jest-preset.js +87 -0
- package/dist/config/jest/web/jest.setup.d.ts +8 -0
- package/dist/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/config/jest/web/jest.setup.js +28 -0
- package/dist/config/jest/web/resolver.d.ts +4 -0
- package/dist/config/jest/web/resolver.d.ts.map +1 -0
- package/dist/config/jest/web/resolver.js +38 -0
- package/dist/config/jest/web/webBabelConfig.d.ts +10 -0
- package/dist/config/jest/web/webBabelConfig.d.ts.map +1 -0
- package/dist/config/jest/web/webBabelConfig.js +18 -0
- package/dist/web/global.d.ts +2 -2
- package/dist/web/global.d.ts.map +1 -1
- package/package.json +20 -11
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/code.js +0 -28
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-commented-exports/output.js +0 -35
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/code.js +0 -7
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-and-other-named-export/output.js +0 -6
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/code.js +0 -3
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-default-export/output.js +0 -3
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/code.js +0 -28
- package/config/jest/babelPlugins/__tests__/__fixtures__/cell/cell-with-required-exports/output.js +0 -34
- package/config/jest/babelPlugins/__tests__/__fixtures__/viteDistDir/client-build-manifest.json +0 -59
- package/config/jest/babelPlugins/__tests__/babel-plugin-redwood-cell.test.ts +0 -11
- package/config/jest/package.json +0 -3
|
@@ -0,0 +1,267 @@
|
|
|
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, dbSchemaPath } = global.__RWJS__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 FOREIGN_KEY_ERRORS = [1451, 1811, 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, getSchema } = await import("@prisma/internals");
|
|
62
|
+
const datamodel = await getSchema(dbSchemaPath);
|
|
63
|
+
const schema = await getDMMF({ datamodel });
|
|
64
|
+
const schemaModels = schema.datamodel.models.map(
|
|
65
|
+
(m) => m.dbName || m.name
|
|
66
|
+
);
|
|
67
|
+
if (import_node_fs.default.existsSync(TEARDOWN_CACHE_PATH)) {
|
|
68
|
+
teardownOrder = JSON.parse(import_node_fs.default.readFileSync(TEARDOWN_CACHE_PATH).toString());
|
|
69
|
+
}
|
|
70
|
+
if (teardownOrder.length !== schemaModels.length) {
|
|
71
|
+
teardownOrder = schemaModels;
|
|
72
|
+
}
|
|
73
|
+
originalTeardownOrder = deepCopy(teardownOrder);
|
|
74
|
+
};
|
|
75
|
+
let quoteStyle;
|
|
76
|
+
const getQuoteStyle = async () => {
|
|
77
|
+
const { getConfig: getPrismaConfig, getSchema } = await import("@prisma/internals");
|
|
78
|
+
const datamodel = await getSchema(dbSchemaPath);
|
|
79
|
+
if (!quoteStyle) {
|
|
80
|
+
const config = await getPrismaConfig({
|
|
81
|
+
datamodel
|
|
82
|
+
});
|
|
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 && FOREIGN_KEY_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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;AAqCtC,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,CAkHzB"}
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
"data",
|
|
29
|
+
"isEmpty",
|
|
30
|
+
"afterQuery",
|
|
31
|
+
"Loading",
|
|
32
|
+
"Success",
|
|
33
|
+
"Failure",
|
|
34
|
+
"Empty"
|
|
35
|
+
];
|
|
36
|
+
function isExpectedExport(name) {
|
|
37
|
+
return name !== void 0 && EXPECTED_EXPORTS_FROM_CELL.includes(name);
|
|
38
|
+
}
|
|
39
|
+
function babel_plugin_redwood_cell_default({
|
|
40
|
+
types
|
|
41
|
+
}) {
|
|
42
|
+
return {
|
|
43
|
+
name: "babel-plugin-redwood-cell",
|
|
44
|
+
visitor: {
|
|
45
|
+
ExportDefaultDeclaration(path, state) {
|
|
46
|
+
state.hasDefaultExport = true;
|
|
47
|
+
},
|
|
48
|
+
ExportNamedDeclaration(path, state) {
|
|
49
|
+
const declaration = path.node.declaration;
|
|
50
|
+
if (!declaration) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
let name;
|
|
54
|
+
if (declaration.type === "VariableDeclaration") {
|
|
55
|
+
const id = declaration.declarations[0].id;
|
|
56
|
+
if (id.type === "Identifier") {
|
|
57
|
+
name = id.name;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (declaration.type === "FunctionDeclaration") {
|
|
61
|
+
name = declaration?.id?.name;
|
|
62
|
+
}
|
|
63
|
+
if (isExpectedExport(name)) {
|
|
64
|
+
state.exportNames.push(name);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
Program: {
|
|
68
|
+
enter(_path, state) {
|
|
69
|
+
state.exportNames = [];
|
|
70
|
+
state.hasDefaultExport = false;
|
|
71
|
+
},
|
|
72
|
+
exit(path, state) {
|
|
73
|
+
const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("data");
|
|
74
|
+
if (state.hasDefaultExport || !hasQueryOrDataExport) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const createCellHookName = state.exportNames.includes("data") ? "createServerCell" : "createCell";
|
|
78
|
+
const importFrom = state.exportNames.includes("data") ? "@cedarjs/web/dist/components/cell/createServerCell" : "@cedarjs/web";
|
|
79
|
+
path.node.body.unshift(
|
|
80
|
+
types.importDeclaration(
|
|
81
|
+
[
|
|
82
|
+
types.importSpecifier(
|
|
83
|
+
types.identifier(createCellHookName),
|
|
84
|
+
types.identifier(createCellHookName)
|
|
85
|
+
)
|
|
86
|
+
],
|
|
87
|
+
types.stringLiteral(importFrom)
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
const objectProperties = [
|
|
91
|
+
...state.exportNames.map(
|
|
92
|
+
(name) => types.objectProperty(
|
|
93
|
+
types.identifier(name),
|
|
94
|
+
types.identifier(name),
|
|
95
|
+
false,
|
|
96
|
+
true
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
];
|
|
100
|
+
if (state.file.opts.filename) {
|
|
101
|
+
objectProperties.push(
|
|
102
|
+
types.objectProperty(
|
|
103
|
+
types.identifier("displayName"),
|
|
104
|
+
types.stringLiteral((0, import_node_path.parse)(state.file.opts.filename).name),
|
|
105
|
+
false,
|
|
106
|
+
true
|
|
107
|
+
)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
path.node.body.push(
|
|
111
|
+
types.exportDefaultDeclaration(
|
|
112
|
+
types.callExpression(types.identifier(createCellHookName), [
|
|
113
|
+
types.objectExpression(objectProperties)
|
|
114
|
+
])
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedwoodWebJestEnv.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/web/RedwoodWebJestEnv.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAIxD,cAAM,yBAA0B,SAAQ,eAAe;IAC/C,KAAK;CAaZ;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 RedwoodWebJestEnv_exports = {};
|
|
20
|
+
__export(RedwoodWebJestEnv_exports, {
|
|
21
|
+
default: () => RedwoodWebJestEnv_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(RedwoodWebJestEnv_exports);
|
|
24
|
+
var import_node_util = require("node:util");
|
|
25
|
+
var import_jest_environment_jsdom = require("jest-environment-jsdom");
|
|
26
|
+
class RedwoodWebJestEnvironment extends import_jest_environment_jsdom.TestEnvironment {
|
|
27
|
+
async setup() {
|
|
28
|
+
await super.setup();
|
|
29
|
+
if (typeof this.global.TextEncoder === "undefined") {
|
|
30
|
+
this.global.TextEncoder = import_node_util.TextEncoder;
|
|
31
|
+
this.global.TextDecoder = import_node_util.TextDecoder;
|
|
32
|
+
}
|
|
33
|
+
if (typeof this.global.crypto.subtle === "undefined") {
|
|
34
|
+
this.global.crypto.subtle = {};
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var RedwoodWebJestEnv_default = RedwoodWebJestEnvironment;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../../src/config/jest/web/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAOlC,QAAA,MAAM,MAAM,EAAE,MAgFb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,117 @@
|
|
|
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 jest_preset_exports = {};
|
|
30
|
+
__export(jest_preset_exports, {
|
|
31
|
+
default: () => jest_preset_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(jest_preset_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
+
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
37
|
+
const NODE_MODULES_PATH = import_node_path.default.join(rwjsPaths.base, "node_modules");
|
|
38
|
+
const config = {
|
|
39
|
+
// To make sure other config option which depends on rootDir always
|
|
40
|
+
// use correct path, for example, coverageDirectory
|
|
41
|
+
rootDir: rwjsPaths.base,
|
|
42
|
+
roots: [import_node_path.default.join(rwjsPaths.web.src)],
|
|
43
|
+
testEnvironment: import_node_path.default.join(__dirname, "./RedwoodWebJestEnv.js"),
|
|
44
|
+
displayName: {
|
|
45
|
+
color: "blueBright",
|
|
46
|
+
name: "web"
|
|
47
|
+
},
|
|
48
|
+
globals: {
|
|
49
|
+
__RWJS_TESTROOT_DIR: import_node_path.default.join(rwjsPaths.web.src),
|
|
50
|
+
// used in jest setup to load mocks
|
|
51
|
+
RWJS_ENV: {
|
|
52
|
+
RWJS_API_URL: "",
|
|
53
|
+
RWJS_API_GRAPHQL_URL: "/",
|
|
54
|
+
__REDWOOD__APP_TITLE: "Redwood App"
|
|
55
|
+
},
|
|
56
|
+
RWJS_DEBUG_ENV: {
|
|
57
|
+
RWJS_SRC_ROOT: rwjsPaths.web.src
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
collectCoverageFrom: [
|
|
61
|
+
"**/*.{js,jsx,ts,tsx}",
|
|
62
|
+
"!**/node_modules/**",
|
|
63
|
+
"!**/dist/**"
|
|
64
|
+
],
|
|
65
|
+
coverageDirectory: import_node_path.default.join(rwjsPaths.base, "coverage"),
|
|
66
|
+
watchPlugins: [
|
|
67
|
+
"jest-watch-typeahead/filename",
|
|
68
|
+
"jest-watch-typeahead/testname"
|
|
69
|
+
],
|
|
70
|
+
setupFilesAfterEnv: [import_node_path.default.resolve(__dirname, "./jest.setup.js")],
|
|
71
|
+
moduleNameMapper: {
|
|
72
|
+
/**
|
|
73
|
+
* Make sure modules that require different versions of these
|
|
74
|
+
* dependencies end up using the same one.
|
|
75
|
+
*/
|
|
76
|
+
"^react$": import_node_path.default.join(NODE_MODULES_PATH, "react"),
|
|
77
|
+
"^react-dom$": import_node_path.default.join(NODE_MODULES_PATH, "react-dom"),
|
|
78
|
+
"^@apollo/client/react$": import_node_path.default.join(
|
|
79
|
+
NODE_MODULES_PATH,
|
|
80
|
+
"@apollo/client/react"
|
|
81
|
+
),
|
|
82
|
+
// We replace imports to "@cedarjs/router" with our own "mock" implementation.
|
|
83
|
+
"^@cedarjs/router$": import_node_path.default.join(
|
|
84
|
+
NODE_MODULES_PATH,
|
|
85
|
+
"@cedarjs/testing/dist/cjs/web/MockRouter.js"
|
|
86
|
+
),
|
|
87
|
+
"^@cedarjs/web$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/web/dist/cjs"),
|
|
88
|
+
// This allows us to mock `createAuthentication` which is used by auth
|
|
89
|
+
// clients, which in turn lets us mock `useAuth` in tests
|
|
90
|
+
"^@cedarjs/auth$": import_node_path.default.join(
|
|
91
|
+
NODE_MODULES_PATH,
|
|
92
|
+
"@cedarjs/testing/dist/cjs/web/mockAuth.js"
|
|
93
|
+
),
|
|
94
|
+
// @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
|
|
95
|
+
// This is to prevent web stuff leaking into api, and vice versa
|
|
96
|
+
"^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
|
|
97
|
+
"~__REDWOOD__USER_ROUTES_FOR_MOCK": rwjsPaths.web.routes,
|
|
98
|
+
"~__REDWOOD__USER_AUTH_FOR_MOCK": import_node_path.default.join(rwjsPaths.web.src, "auth"),
|
|
99
|
+
/**
|
|
100
|
+
* Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
|
|
101
|
+
*/
|
|
102
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|css)$": "@cedarjs/testing/dist/cjs/web/fileMock.js"
|
|
103
|
+
},
|
|
104
|
+
transform: {
|
|
105
|
+
"\\.[jt]sx?$": [
|
|
106
|
+
"babel-jest",
|
|
107
|
+
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
108
|
+
// that's why these must be serializable. Passing the reference to a config instead.
|
|
109
|
+
{
|
|
110
|
+
configFile: import_node_path.default.resolve(__dirname, "./webBabelConfig.js")
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
},
|
|
114
|
+
resolver: import_node_path.default.resolve(__dirname, "./resolver.js"),
|
|
115
|
+
testPathIgnorePatterns: [".(stories|mock).[jt]sx?$"]
|
|
116
|
+
};
|
|
117
|
+
var jest_preset_default = config;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
2
|
+
import 'whatwg-fetch';
|
|
3
|
+
import { mockCurrentUser as _mockCurrentUser } from '../../../web/mockRequests.js';
|
|
4
|
+
declare global {
|
|
5
|
+
var __RWJS_TESTROOT_DIR: string;
|
|
6
|
+
var mockCurrentUser: typeof _mockCurrentUser;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=jest.setup.d.ts.map
|