@cedarjs/testing 7.0.0-canary.3259 → 7.0.0-rc.127
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 +48 -0
- 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 +34 -0
- 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 +63 -0
- 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 -0
- 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 +140 -0
- 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 +267 -0
- package/config/jest/api/package.json +8 -0
- 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 +122 -0
- 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 +37 -0
- 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 +43 -0
- 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 -0
- package/config/jest/web/jest-fixed-jsdom.d.js +1 -0
- 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 +224 -0
- package/config/jest/web/jest.setup.d.ts +7 -0
- package/config/jest/web/jest.setup.d.ts.map +1 -0
- package/config/jest/web/jest.setup.js +21 -0
- package/config/jest/web/package.json +8 -0
- 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 +30 -0
- 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 +48 -0
- package/config/package.json +1 -0
- package/dist/api/mockContext.d.ts +1 -1
- package/dist/api/mockContext.d.ts.map +1 -1
- package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.d.ts.map +1 -1
- package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +1 -6
- package/dist/api/vitest/vitest-api.setup.d.ts.map +1 -1
- package/dist/api/vitest/vitest-api.setup.js +22 -9
- package/dist/cjs/api/apiFunction.d.ts +37 -0
- package/dist/cjs/api/apiFunction.d.ts.map +1 -0
- package/dist/cjs/api/apiFunction.js +89 -0
- package/dist/cjs/api/checkTestDatabase.d.ts +50 -0
- package/dist/cjs/api/checkTestDatabase.d.ts.map +1 -0
- package/dist/cjs/api/checkTestDatabase.js +182 -0
- package/dist/cjs/api/directive.d.ts +51 -0
- package/dist/cjs/api/directive.d.ts.map +1 -0
- package/dist/cjs/api/directive.js +77 -0
- package/dist/cjs/api/index.d.ts +4 -0
- package/dist/cjs/api/index.d.ts.map +1 -0
- package/dist/cjs/api/index.js +26 -0
- package/dist/cjs/api/mockContext.d.ts +5 -0
- package/dist/cjs/api/mockContext.d.ts.map +1 -0
- package/dist/cjs/api/mockContext.js +58 -0
- package/dist/cjs/api/scenario.d.ts +108 -0
- package/dist/cjs/api/scenario.d.ts.map +1 -0
- package/dist/cjs/api/scenario.js +30 -0
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +86 -0
- package/dist/cjs/api/vitest/index.js +34 -0
- package/dist/cjs/api/vitest/vite-plugin-auto-import.js +71 -0
- package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +69 -0
- package/dist/cjs/api/vitest/vite-plugin-track-db-imports.js +47 -0
- package/dist/cjs/api/vitest/vitest-api.setup.js +270 -0
- package/dist/cjs/cache/index.d.ts +50 -0
- package/dist/cjs/cache/index.d.ts.map +1 -0
- package/dist/cjs/cache/index.js +104 -0
- 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 +63 -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 +140 -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 +122 -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 +43 -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-fixed-jsdom.d.js +1 -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 +224 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts +7 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/cjs/config/jest/web/jest.setup.js +21 -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/package.json +1 -0
- package/dist/cjs/web/MockParamsProvider.d.ts +7 -0
- package/dist/cjs/web/MockParamsProvider.d.ts.map +1 -0
- package/dist/cjs/web/MockParamsProvider.js +44 -0
- package/dist/cjs/web/MockProviders.d.ts +5 -0
- package/dist/cjs/web/MockProviders.d.ts.map +1 -0
- package/dist/cjs/web/MockProviders.js +66 -0
- package/dist/cjs/web/MockRouter.d.ts +11 -0
- package/dist/cjs/web/MockRouter.d.ts.map +1 -0
- package/dist/cjs/web/MockRouter.js +48 -0
- package/dist/cjs/web/customRender.d.ts +6 -0
- package/dist/cjs/web/customRender.d.ts.map +1 -0
- package/dist/cjs/web/customRender.js +54 -0
- package/dist/cjs/web/fileMock.d.ts +10 -0
- package/dist/cjs/web/fileMock.d.ts.map +1 -0
- package/dist/cjs/web/fileMock.js +24 -0
- package/dist/cjs/web/findCellMocks.d.ts +2 -0
- package/dist/cjs/web/findCellMocks.d.ts.map +1 -0
- package/dist/cjs/web/findCellMocks.js +45 -0
- package/dist/cjs/web/globRoutesImporter.d.ts +13 -0
- package/dist/cjs/web/globRoutesImporter.d.ts.map +1 -0
- package/dist/cjs/web/globRoutesImporter.js +46 -0
- package/dist/cjs/web/global.d.ts +6 -0
- package/dist/cjs/web/global.d.ts.map +1 -0
- package/dist/cjs/web/global.js +1 -0
- package/dist/cjs/web/index.d.ts +6 -0
- package/dist/cjs/web/index.d.ts.map +1 -0
- package/dist/cjs/web/index.js +41 -0
- package/dist/cjs/web/mockAuth.d.ts +29 -0
- package/dist/cjs/web/mockAuth.d.ts.map +1 -0
- package/dist/cjs/web/mockAuth.js +89 -0
- package/dist/cjs/web/mockRequests.d.ts +72 -0
- package/dist/cjs/web/mockRequests.d.ts.map +1 -0
- package/dist/cjs/web/mockRequests.js +210 -0
- package/dist/cjs/web/vitest/index.js +37 -0
- package/dist/cjs/web/vitest/vite-plugin-auto-import.js +60 -0
- package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +51 -0
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.js +42 -0
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.js +43 -0
- package/dist/cjs/web/vitest/vitest-web.setup.js +19 -0
- 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 +36 -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 +15 -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 +110 -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 +102 -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 +27 -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 +13 -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 +15 -0
- package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -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 +194 -0
- package/dist/config/jest/web/jest.setup.d.ts +7 -0
- package/dist/config/jest/web/jest.setup.d.ts.map +1 -0
- package/dist/config/jest/web/jest.setup.js +27 -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 +42 -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/MockParamsProvider.d.ts.map +1 -1
- package/dist/web/MockParamsProvider.js +1 -10
- package/dist/web/MockRouter.d.ts.map +1 -1
- package/dist/web/fileMock.d.ts +10 -0
- package/dist/web/fileMock.d.ts.map +1 -0
- package/dist/web/fileMock.js +4 -0
- package/dist/web/mockRequests.d.ts +0 -14
- package/dist/web/mockRequests.d.ts.map +1 -1
- package/dist/web/mockRequests.js +0 -8
- package/package.json +95 -22
- package/dist/api/vitest/teardown.d.ts +0 -18
- package/dist/api/vitest/teardown.d.ts.map +0 -1
- package/dist/api/vitest/teardown.js +0 -43
|
@@ -0,0 +1,210 @@
|
|
|
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 mockRequests_exports = {};
|
|
30
|
+
__export(mockRequests_exports, {
|
|
31
|
+
closeServer: () => closeServer,
|
|
32
|
+
mockCurrentUser: () => mockCurrentUser,
|
|
33
|
+
mockGraphQLMutation: () => mockGraphQLMutation,
|
|
34
|
+
mockGraphQLQuery: () => mockGraphQLQuery,
|
|
35
|
+
mockedUserMeta: () => mockedUserMeta,
|
|
36
|
+
registerHandler: () => registerHandler,
|
|
37
|
+
setupRequestHandlers: () => setupRequestHandlers,
|
|
38
|
+
startMSW: () => startMSW
|
|
39
|
+
});
|
|
40
|
+
module.exports = __toCommonJS(mockRequests_exports);
|
|
41
|
+
var import_msw = require("msw");
|
|
42
|
+
let REQUEST_HANDLER_QUEUE = [];
|
|
43
|
+
let SERVER_INSTANCE;
|
|
44
|
+
const MSW_NODE_SPECIFIER = "msw/node";
|
|
45
|
+
const startMSW = async (target, options) => {
|
|
46
|
+
if (SERVER_INSTANCE) {
|
|
47
|
+
return SERVER_INSTANCE;
|
|
48
|
+
}
|
|
49
|
+
if (target === "browsers") {
|
|
50
|
+
const { setupWorker } = require("msw/browser");
|
|
51
|
+
const worker = setupWorker();
|
|
52
|
+
SERVER_INSTANCE = worker;
|
|
53
|
+
await worker.start(options);
|
|
54
|
+
} else {
|
|
55
|
+
const { setupServer } = require(
|
|
56
|
+
/* @vite-ignore */
|
|
57
|
+
MSW_NODE_SPECIFIER
|
|
58
|
+
);
|
|
59
|
+
const server = setupServer();
|
|
60
|
+
SERVER_INSTANCE = server;
|
|
61
|
+
server.listen(options);
|
|
62
|
+
}
|
|
63
|
+
return SERVER_INSTANCE;
|
|
64
|
+
};
|
|
65
|
+
const setupRequestHandlers = () => {
|
|
66
|
+
SERVER_INSTANCE?.resetHandlers();
|
|
67
|
+
for (const handler of REQUEST_HANDLER_QUEUE) {
|
|
68
|
+
SERVER_INSTANCE?.use(handler);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const closeServer = () => {
|
|
72
|
+
if (!SERVER_INSTANCE) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if ("close" in SERVER_INSTANCE) {
|
|
76
|
+
SERVER_INSTANCE.close();
|
|
77
|
+
} else {
|
|
78
|
+
SERVER_INSTANCE.stop();
|
|
79
|
+
}
|
|
80
|
+
SERVER_INSTANCE = void 0;
|
|
81
|
+
};
|
|
82
|
+
const registerHandler = (handler) => {
|
|
83
|
+
if (!SERVER_INSTANCE) {
|
|
84
|
+
REQUEST_HANDLER_QUEUE = [...REQUEST_HANDLER_QUEUE, handler];
|
|
85
|
+
} else {
|
|
86
|
+
SERVER_INSTANCE.use(handler);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const mockGraphQL = (type, operation, data, responseEnhancer) => {
|
|
90
|
+
const resolver = async ({
|
|
91
|
+
request,
|
|
92
|
+
query,
|
|
93
|
+
operationName,
|
|
94
|
+
variables,
|
|
95
|
+
cookies
|
|
96
|
+
}) => {
|
|
97
|
+
let d = void 0;
|
|
98
|
+
let status = 200;
|
|
99
|
+
let statusText;
|
|
100
|
+
let delayDurationMs;
|
|
101
|
+
let errorList;
|
|
102
|
+
let extensions;
|
|
103
|
+
let explicitData;
|
|
104
|
+
const extraFields = {};
|
|
105
|
+
const headers = new Headers();
|
|
106
|
+
if (typeof data === "function") {
|
|
107
|
+
const ctx = {
|
|
108
|
+
status: (code, text) => {
|
|
109
|
+
status = code;
|
|
110
|
+
statusText = text;
|
|
111
|
+
},
|
|
112
|
+
delay: (durationMs) => {
|
|
113
|
+
delayDurationMs = durationMs;
|
|
114
|
+
},
|
|
115
|
+
errors: (errors) => {
|
|
116
|
+
errorList = errors;
|
|
117
|
+
},
|
|
118
|
+
set: (name, value) => {
|
|
119
|
+
if (typeof name === "object") {
|
|
120
|
+
for (const [headerName, headerValue] of Object.entries(name)) {
|
|
121
|
+
headers.set(headerName, headerValue);
|
|
122
|
+
}
|
|
123
|
+
} else if (typeof value !== "undefined") {
|
|
124
|
+
headers.set(name, value);
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
cookie: (name, value) => {
|
|
128
|
+
headers.append("Set-Cookie", `${name}=${value}`);
|
|
129
|
+
},
|
|
130
|
+
extensions: (ext) => {
|
|
131
|
+
extensions = ext;
|
|
132
|
+
},
|
|
133
|
+
field: (fieldName, value) => {
|
|
134
|
+
extraFields[fieldName] = value;
|
|
135
|
+
},
|
|
136
|
+
data: (dataValue) => {
|
|
137
|
+
explicitData = dataValue;
|
|
138
|
+
},
|
|
139
|
+
fetch: (input, init) => fetch((0, import_msw.bypass)(input, init))
|
|
140
|
+
};
|
|
141
|
+
const req = {
|
|
142
|
+
request,
|
|
143
|
+
query,
|
|
144
|
+
operationName,
|
|
145
|
+
variables,
|
|
146
|
+
cookies,
|
|
147
|
+
url: new URL(request.url),
|
|
148
|
+
headers: request.headers,
|
|
149
|
+
method: request.method
|
|
150
|
+
};
|
|
151
|
+
d = await data(variables, { req, ctx });
|
|
152
|
+
} else {
|
|
153
|
+
d = data;
|
|
154
|
+
}
|
|
155
|
+
if (responseEnhancer === "networkError") {
|
|
156
|
+
return import_msw.HttpResponse.error();
|
|
157
|
+
}
|
|
158
|
+
if (typeof delayDurationMs !== "undefined") {
|
|
159
|
+
await (0, import_msw.delay)(delayDurationMs);
|
|
160
|
+
}
|
|
161
|
+
const body = { ...extraFields };
|
|
162
|
+
const bodyData = explicitData ?? d;
|
|
163
|
+
if (typeof bodyData !== "undefined") {
|
|
164
|
+
body.data = bodyData;
|
|
165
|
+
}
|
|
166
|
+
if (typeof errorList !== "undefined") {
|
|
167
|
+
body.errors = errorList;
|
|
168
|
+
}
|
|
169
|
+
if (typeof extensions !== "undefined") {
|
|
170
|
+
body.extensions = extensions;
|
|
171
|
+
}
|
|
172
|
+
return import_msw.HttpResponse.json(body, { status, statusText, headers });
|
|
173
|
+
};
|
|
174
|
+
registerHandler(
|
|
175
|
+
import_msw.graphql[type](operation, resolver, {
|
|
176
|
+
once: responseEnhancer === "once"
|
|
177
|
+
})
|
|
178
|
+
);
|
|
179
|
+
return data;
|
|
180
|
+
};
|
|
181
|
+
const mockGraphQLQuery = (operation, data, responseEnhancer) => {
|
|
182
|
+
return mockGraphQL("query", operation, data, responseEnhancer);
|
|
183
|
+
};
|
|
184
|
+
const mockGraphQLMutation = (operation, data, responseEnhancer) => {
|
|
185
|
+
return mockGraphQL("mutation", operation, data, responseEnhancer);
|
|
186
|
+
};
|
|
187
|
+
const mockedUserMeta = {
|
|
188
|
+
currentUser: null
|
|
189
|
+
};
|
|
190
|
+
const mockCurrentUser = (user) => {
|
|
191
|
+
mockedUserMeta.currentUser = user;
|
|
192
|
+
mockGraphQLQuery("__CEDAR__AUTH_GET_CURRENT_USER", () => {
|
|
193
|
+
return {
|
|
194
|
+
cedar: {
|
|
195
|
+
currentUser: user
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
201
|
+
0 && (module.exports = {
|
|
202
|
+
closeServer,
|
|
203
|
+
mockCurrentUser,
|
|
204
|
+
mockGraphQLMutation,
|
|
205
|
+
mockGraphQLQuery,
|
|
206
|
+
mockedUserMeta,
|
|
207
|
+
registerHandler,
|
|
208
|
+
setupRequestHandlers,
|
|
209
|
+
startMSW
|
|
210
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var vitest_exports = {};
|
|
20
|
+
__export(vitest_exports, {
|
|
21
|
+
autoImportsPlugin: () => import_vite_plugin_auto_import.autoImportsPlugin,
|
|
22
|
+
cedarJsRouterImportTransformPlugin: () => import_vite_plugin_cedarjs_router_import_transform.cedarJsRouterImportTransformPlugin,
|
|
23
|
+
cedarVitestWebConfigPlugin: () => import_vite_plugin_cedar_vitest_web_config.cedarVitestWebConfigPlugin,
|
|
24
|
+
createAuthImportTransformPlugin: () => import_vite_plugin_create_auth_import_transform.createAuthImportTransformPlugin
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(vitest_exports);
|
|
27
|
+
var import_vite_plugin_cedarjs_router_import_transform = require("./vite-plugin-cedarjs-router-import-transform.js");
|
|
28
|
+
var import_vite_plugin_cedar_vitest_web_config = require("./vite-plugin-cedar-vitest-web-config.js");
|
|
29
|
+
var import_vite_plugin_create_auth_import_transform = require("./vite-plugin-create-auth-import-transform.js");
|
|
30
|
+
var import_vite_plugin_auto_import = require("./vite-plugin-auto-import.js");
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
autoImportsPlugin,
|
|
34
|
+
cedarJsRouterImportTransformPlugin,
|
|
35
|
+
cedarVitestWebConfigPlugin,
|
|
36
|
+
createAuthImportTransformPlugin
|
|
37
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var vite_plugin_auto_import_exports = {};
|
|
30
|
+
__export(vite_plugin_auto_import_exports, {
|
|
31
|
+
autoImportsPlugin: () => autoImportsPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_auto_import_exports);
|
|
34
|
+
var import_vite = __toESM(require("unplugin-auto-import/vite"), 1);
|
|
35
|
+
function autoImportsPlugin() {
|
|
36
|
+
return (0, import_vite.default)({
|
|
37
|
+
// targets to transform
|
|
38
|
+
include: [
|
|
39
|
+
/\.[tj]sx?$/
|
|
40
|
+
// .ts, .tsx, .js, .jsx
|
|
41
|
+
],
|
|
42
|
+
// global imports to register
|
|
43
|
+
imports: [
|
|
44
|
+
{
|
|
45
|
+
"@cedarjs/testing/web": [
|
|
46
|
+
"mockGraphQLQuery",
|
|
47
|
+
"mockGraphQLMutation",
|
|
48
|
+
"mockCurrentUser"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
// We provide our mocking types elsewhere and so don't need this plugin to
|
|
53
|
+
// generate them.
|
|
54
|
+
dts: false
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
autoImportsPlugin
|
|
60
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var vite_plugin_cedar_vitest_web_config_exports = {};
|
|
30
|
+
__export(vite_plugin_cedar_vitest_web_config_exports, {
|
|
31
|
+
cedarVitestWebConfigPlugin: () => cedarVitestWebConfigPlugin
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(vite_plugin_cedar_vitest_web_config_exports);
|
|
34
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
|
+
const import_meta = {};
|
|
36
|
+
function cedarVitestWebConfigPlugin() {
|
|
37
|
+
return {
|
|
38
|
+
name: "cedar-vitest-web-config",
|
|
39
|
+
config: () => {
|
|
40
|
+
return {
|
|
41
|
+
test: {
|
|
42
|
+
setupFiles: [import_node_path.default.join(import_meta.dirname, "vitest-web.setup.js")]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
49
|
+
0 && (module.exports = {
|
|
50
|
+
cedarVitestWebConfigPlugin
|
|
51
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
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 vite_plugin_cedarjs_router_import_transform_exports = {};
|
|
20
|
+
__export(vite_plugin_cedarjs_router_import_transform_exports, {
|
|
21
|
+
cedarJsRouterImportTransformPlugin: () => cedarJsRouterImportTransformPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_cedarjs_router_import_transform_exports);
|
|
24
|
+
function cedarJsRouterImportTransformPlugin() {
|
|
25
|
+
return {
|
|
26
|
+
name: "cedarjs-router-import-transform",
|
|
27
|
+
enforce: "pre",
|
|
28
|
+
transform(code, id) {
|
|
29
|
+
if (id.includes("/web/src")) {
|
|
30
|
+
code = code.replace(
|
|
31
|
+
/['"]@cedarjs\/router['"]/,
|
|
32
|
+
"'@cedarjs/testing/web/MockRouter.js'"
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return code;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
cedarJsRouterImportTransformPlugin
|
|
42
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
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 vite_plugin_create_auth_import_transform_exports = {};
|
|
20
|
+
__export(vite_plugin_create_auth_import_transform_exports, {
|
|
21
|
+
createAuthImportTransformPlugin: () => createAuthImportTransformPlugin
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(vite_plugin_create_auth_import_transform_exports);
|
|
24
|
+
function createAuthImportTransformPlugin() {
|
|
25
|
+
return {
|
|
26
|
+
name: "create-auth-import-transform",
|
|
27
|
+
enforce: "pre",
|
|
28
|
+
transform(code, id) {
|
|
29
|
+
if (id.endsWith("/web/src/auth.ts") || id.endsWith("/web/src/auth.js")) {
|
|
30
|
+
code = code.replace(
|
|
31
|
+
/(^\s*import\s*{[^}]*?)(\bcreateAuth\b)(,?)([^}]*})/m,
|
|
32
|
+
"$1$4"
|
|
33
|
+
);
|
|
34
|
+
code = "import { createAuthentication as createAuth } from '@cedarjs/testing/auth'\n" + code;
|
|
35
|
+
}
|
|
36
|
+
return code;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
createAuthImportTransformPlugin
|
|
43
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var import_vitest = require("vitest");
|
|
3
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
4
|
+
var import_findCellMocks = require("../findCellMocks.js");
|
|
5
|
+
var import_mockRequests = require("../mockRequests.js");
|
|
6
|
+
(0, import_vitest.beforeAll)(async () => {
|
|
7
|
+
const cellMocks = (0, import_findCellMocks.findCellMocks)((0, import_project_config.getPaths)().web.src);
|
|
8
|
+
for (const m of cellMocks) {
|
|
9
|
+
await import(m);
|
|
10
|
+
}
|
|
11
|
+
await (0, import_mockRequests.startMSW)("node");
|
|
12
|
+
(0, import_mockRequests.setupRequestHandlers)();
|
|
13
|
+
});
|
|
14
|
+
(0, import_vitest.afterEach)(() => {
|
|
15
|
+
(0, import_mockRequests.setupRequestHandlers)();
|
|
16
|
+
});
|
|
17
|
+
(0, import_vitest.afterAll)(() => {
|
|
18
|
+
(0, import_mockRequests.closeServer)();
|
|
19
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EnvironmentContext, JestEnvironmentConfig } from '@jest/environment';
|
|
2
|
+
import { TestEnvironment } from 'jest-environment-node';
|
|
3
|
+
declare class RedwoodApiJestEnvironment extends TestEnvironment {
|
|
4
|
+
private testPath;
|
|
5
|
+
constructor(config: JestEnvironmentConfig, context: EnvironmentContext);
|
|
6
|
+
setup(): Promise<void>;
|
|
7
|
+
teardown(): Promise<void>;
|
|
8
|
+
getVmContext(): import("vm").Context | null;
|
|
9
|
+
}
|
|
10
|
+
export default RedwoodApiJestEnvironment;
|
|
11
|
+
//# sourceMappingURL=RedwoodApiJestEnv.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RedwoodApiJestEnv.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/RedwoodApiJestEnv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,cAAM,yBAA0B,SAAQ,eAAe;IACrD,OAAO,CAAC,QAAQ,CAAQ;gBAEZ,MAAM,EAAE,qBAAqB,EAAE,OAAO,EAAE,kBAAkB;IAKhE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,YAAY;CAUb;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { TestEnvironment } from "jest-environment-node";
|
|
2
|
+
class RedwoodApiJestEnvironment extends TestEnvironment {
|
|
3
|
+
testPath;
|
|
4
|
+
constructor(config, context) {
|
|
5
|
+
super(config, context);
|
|
6
|
+
this.testPath = context.testPath;
|
|
7
|
+
}
|
|
8
|
+
async setup() {
|
|
9
|
+
await super.setup();
|
|
10
|
+
this.global.testPath = this.testPath;
|
|
11
|
+
}
|
|
12
|
+
async teardown() {
|
|
13
|
+
await super.teardown();
|
|
14
|
+
}
|
|
15
|
+
getVmContext() {
|
|
16
|
+
return super.getVmContext();
|
|
17
|
+
}
|
|
18
|
+
// async handleTestEvent(event, state) {
|
|
19
|
+
// if (event.name === 'test_start') {
|
|
20
|
+
// // Link to event docs:
|
|
21
|
+
// // https://github.com/facebook/jest/blob/master/packages/jest-types/src/Circus.ts
|
|
22
|
+
// }
|
|
23
|
+
// }
|
|
24
|
+
}
|
|
25
|
+
var RedwoodApiJestEnv_default = RedwoodApiJestEnvironment;
|
|
26
|
+
export {
|
|
27
|
+
RedwoodApiJestEnv_default as default
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiBabelConfig.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/apiBabelConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAG7B,MAAM,uBAAuB,CAAA;AAO9B,KAAK,UAAU,GAAG,IAAI,CACpB,UAAU,CAAC,OAAO,4BAA4B,CAAC,EAC/C,SAAS,CACV,CAAA;AAED,QAAA,MAAM,MAAM,EAAE,UAMb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getApiSideDefaultBabelConfig,
|
|
3
|
+
getApiSideBabelPresets,
|
|
4
|
+
getApiSideBabelPlugins
|
|
5
|
+
} from "@cedarjs/babel-config";
|
|
6
|
+
const { babelrc: _b, ...defaultBabelConfig } = getApiSideDefaultBabelConfig();
|
|
7
|
+
const config = {
|
|
8
|
+
...defaultBabelConfig,
|
|
9
|
+
plugins: getApiSideBabelPlugins(),
|
|
10
|
+
presets: getApiSideBabelPresets({
|
|
11
|
+
presetEnv: true
|
|
12
|
+
// jest needs code transpiled
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
var apiBabelConfig_default = config;
|
|
16
|
+
export {
|
|
17
|
+
apiBabelConfig_default as default
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;AAW/B,0CAqCC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import "dotenv-defaults/config";
|
|
3
|
+
import execa from "execa";
|
|
4
|
+
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
6
|
+
import {
|
|
7
|
+
checkTestDatabaseUrlMatchesProvider,
|
|
8
|
+
redactDatabaseUrl
|
|
9
|
+
} from "../../../api/checkTestDatabase.js";
|
|
10
|
+
async function globalSetup_default() {
|
|
11
|
+
if (process.env.SKIP_DB_PUSH === "1") {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const cedarPaths = getPaths();
|
|
15
|
+
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
16
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
17
|
+
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
18
|
+
await checkTestDatabaseUrlMatchesProvider(
|
|
19
|
+
process.env.DATABASE_URL,
|
|
20
|
+
usedFallback
|
|
21
|
+
);
|
|
22
|
+
console.log(
|
|
23
|
+
`Setting up test database: ${redactDatabaseUrl(process.env.DATABASE_URL)}`
|
|
24
|
+
);
|
|
25
|
+
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
26
|
+
const pm = getPackageManager();
|
|
27
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
28
|
+
execa.sync(pmExec, ["cedar", ...command], {
|
|
29
|
+
cwd: cedarPaths.api.base,
|
|
30
|
+
stdio: "inherit",
|
|
31
|
+
env: process.env
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
globalSetup_default as default
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAK9C,SAAS,UAAU,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
try {
|
|
4
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
+
} catch (e) {
|
|
6
|
+
throw mod = 0, e;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
import * as jestPreset from "./jest-preset.js";
|
|
10
|
+
var require_api = __commonJS({
|
|
11
|
+
"src/config/jest/api/index.ts"(exports, module) {
|
|
12
|
+
module.exports = jestPreset;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export default require_api();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/jest-preset.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAkClC,QAAA,MAAM,MAAM,EAAE,MA0Fb,CAAA;AAED,eAAe,MAAM,CAAA"}
|