@cedarjs/testing 5.0.7-next.338 → 5.0.7
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/apiBabelConfig.d.ts.map +1 -1
- package/config/jest/api/apiBabelConfig.js +3 -1
- package/config/jest/api/globalSetup.d.ts.map +1 -1
- package/config/jest/api/globalSetup.js +0 -9
- package/config/jest/api/jest-preset.d.ts.map +1 -1
- package/config/jest/api/jest-preset.js +3 -38
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +1 -2
- package/config/jest/web/RedwoodWebJestEnv.d.ts +2 -2
- package/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -1
- package/config/jest/web/RedwoodWebJestEnv.js +7 -12
- package/config/jest/web/jest-preset.d.ts.map +1 -1
- package/config/jest/web/jest-preset.js +30 -135
- package/config/jest/web/jest.setup.d.ts +1 -0
- package/config/jest/web/jest.setup.d.ts.map +1 -1
- package/config/jest/web/jest.setup.js +1 -0
- package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
- package/dist/api/vitest/CedarApiVitestEnv.js +1 -13
- package/dist/api/vitest/vite-plugin-cedar-vitest-api-config.js +7 -7
- package/dist/api/vitest/vitest-api.setup.js +4 -4
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +1 -10
- package/dist/cjs/api/vitest/vite-plugin-cedar-vitest-api-config.js +7 -7
- package/dist/cjs/api/vitest/vitest-api.setup.js +4 -4
- package/dist/cjs/config/jest/api/apiBabelConfig.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/apiBabelConfig.js +3 -1
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/globalSetup.js +0 -9
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/jest-preset.js +3 -38
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
- package/dist/cjs/config/jest/babelPlugins/babel-plugin-redwood-cell.js +1 -2
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts +2 -2
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -1
- package/dist/cjs/config/jest/web/RedwoodWebJestEnv.js +7 -12
- package/dist/cjs/config/jest/web/jest-preset.d.ts.map +1 -1
- package/dist/cjs/config/jest/web/jest-preset.js +30 -135
- package/dist/cjs/config/jest/web/jest.setup.d.ts +1 -0
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -1
- package/dist/cjs/config/jest/web/jest.setup.js +1 -0
- package/dist/cjs/web/MockProviders.js +3 -9
- package/dist/cjs/web/fileMock.d.ts +4 -5
- package/dist/cjs/web/fileMock.d.ts.map +1 -1
- package/dist/cjs/web/mockRequests.d.ts +18 -60
- package/dist/cjs/web/mockRequests.d.ts.map +1 -1
- package/dist/cjs/web/mockRequests.js +36 -107
- package/dist/cjs/web/vitest/index.d.ts +4 -0
- package/dist/cjs/web/vitest/index.d.ts.map +1 -0
- package/dist/cjs/web/vitest/index.js +0 -3
- package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts +2 -0
- package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts.map +1 -0
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +7 -0
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +1 -0
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts +3 -0
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +1 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts.map +1 -1
- package/dist/config/jest/api/apiBabelConfig.js +3 -1
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/config/jest/api/globalSetup.js +0 -12
- package/dist/config/jest/api/index.js +1 -5
- package/dist/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/config/jest/api/jest-preset.js +3 -38
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +1 -2
- package/dist/config/jest/jest-serial-runner.js +1 -5
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts +2 -2
- package/dist/config/jest/web/RedwoodWebJestEnv.d.ts.map +1 -1
- package/dist/config/jest/web/RedwoodWebJestEnv.js +7 -2
- package/dist/config/jest/web/index.js +1 -5
- package/dist/config/jest/web/jest-preset.d.ts.map +1 -1
- package/dist/config/jest/web/jest-preset.js +30 -135
- package/dist/config/jest/web/jest.setup.d.ts +1 -0
- package/dist/config/jest/web/jest.setup.d.ts.map +1 -1
- package/dist/config/jest/web/jest.setup.js +1 -0
- package/dist/config/jest/web/resolver.js +1 -5
- package/dist/web/MockProviders.js +4 -10
- package/dist/web/fileMock.d.ts +4 -5
- package/dist/web/fileMock.d.ts.map +1 -1
- package/dist/web/mockRequests.d.ts +18 -60
- package/dist/web/mockRequests.d.ts.map +1 -1
- package/dist/web/mockRequests.js +37 -108
- package/dist/web/vitest/index.d.ts +0 -1
- package/dist/web/vitest/index.d.ts.map +1 -1
- package/dist/web/vitest/index.js +0 -2
- package/dist/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +1 -1
- package/dist/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +1 -1
- package/package.json +22 -27
- package/config/jest/web/jest-fixed-jsdom.d.js +0 -1
- package/dist/api/checkTestDatabase.d.ts +0 -23
- package/dist/api/checkTestDatabase.d.ts.map +0 -1
- package/dist/api/checkTestDatabase.js +0 -44
- package/dist/cjs/api/checkTestDatabase.d.ts +0 -23
- package/dist/cjs/api/checkTestDatabase.d.ts.map +0 -1
- package/dist/cjs/api/checkTestDatabase.js +0 -69
- package/dist/cjs/config/jest/web/jest-fixed-jsdom.d.js +0 -1
- package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +0 -51
- package/dist/cjs/web/vitest/vitest-web.setup.js +0 -19
- package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -0
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts +0 -12
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts.map +0 -1
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.js +0 -16
- package/dist/web/vitest/vitest-web.setup.d.ts +0 -2
- package/dist/web/vitest/vitest-web.setup.d.ts.map +0 -1
- package/dist/web/vitest/vitest-web.setup.js +0 -18
|
@@ -41,43 +41,28 @@ module.exports = __toCommonJS(mockRequests_exports);
|
|
|
41
41
|
var import_msw = require("msw");
|
|
42
42
|
let REQUEST_HANDLER_QUEUE = [];
|
|
43
43
|
let SERVER_INSTANCE;
|
|
44
|
-
const MSW_NODE_SPECIFIER = "msw/node";
|
|
45
44
|
const startMSW = async (target, options) => {
|
|
46
45
|
if (SERVER_INSTANCE) {
|
|
47
46
|
return SERVER_INSTANCE;
|
|
48
47
|
}
|
|
49
48
|
if (target === "browsers") {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
SERVER_INSTANCE = worker;
|
|
53
|
-
await worker.start(options);
|
|
49
|
+
SERVER_INSTANCE = (0, import_msw.setupWorker)();
|
|
50
|
+
await SERVER_INSTANCE.start(options);
|
|
54
51
|
} else {
|
|
55
|
-
const { setupServer } = require(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
);
|
|
59
|
-
const server = setupServer();
|
|
60
|
-
SERVER_INSTANCE = server;
|
|
61
|
-
server.listen(options);
|
|
52
|
+
const { setupServer } = require("msw/node");
|
|
53
|
+
SERVER_INSTANCE = setupServer();
|
|
54
|
+
await SERVER_INSTANCE.listen(options);
|
|
62
55
|
}
|
|
63
56
|
return SERVER_INSTANCE;
|
|
64
57
|
};
|
|
65
58
|
const setupRequestHandlers = () => {
|
|
66
|
-
SERVER_INSTANCE
|
|
59
|
+
SERVER_INSTANCE.resetHandlers();
|
|
67
60
|
for (const handler of REQUEST_HANDLER_QUEUE) {
|
|
68
|
-
SERVER_INSTANCE
|
|
61
|
+
SERVER_INSTANCE.use(handler);
|
|
69
62
|
}
|
|
70
63
|
};
|
|
71
64
|
const closeServer = () => {
|
|
72
|
-
|
|
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;
|
|
65
|
+
SERVER_INSTANCE.close();
|
|
81
66
|
};
|
|
82
67
|
const registerHandler = (handler) => {
|
|
83
68
|
if (!SERVER_INSTANCE) {
|
|
@@ -87,95 +72,39 @@ const registerHandler = (handler) => {
|
|
|
87
72
|
}
|
|
88
73
|
};
|
|
89
74
|
const mockGraphQL = (type, operation, data, responseEnhancer) => {
|
|
90
|
-
const resolver =
|
|
91
|
-
|
|
92
|
-
|
|
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();
|
|
75
|
+
const resolver = (req, res, ctx) => {
|
|
76
|
+
let d = data;
|
|
77
|
+
let responseTransforms = [];
|
|
106
78
|
if (typeof data === "function") {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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))
|
|
79
|
+
const captureTransform = (fn) => {
|
|
80
|
+
return (...args) => {
|
|
81
|
+
const resTransform = fn(...args);
|
|
82
|
+
responseTransforms = [...responseTransforms, resTransform];
|
|
83
|
+
return resTransform;
|
|
84
|
+
};
|
|
140
85
|
};
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
86
|
+
const newCtx = {
|
|
87
|
+
status: captureTransform(ctx.status),
|
|
88
|
+
delay: captureTransform(ctx.delay),
|
|
89
|
+
errors: captureTransform(ctx.errors),
|
|
90
|
+
set: captureTransform(ctx.set),
|
|
91
|
+
fetch: captureTransform(ctx.fetch),
|
|
92
|
+
data: captureTransform(ctx.data),
|
|
93
|
+
extensions: captureTransform(ctx.extensions),
|
|
94
|
+
cookie: captureTransform(ctx.cookie),
|
|
95
|
+
field: captureTransform(ctx.field)
|
|
150
96
|
};
|
|
151
|
-
d =
|
|
152
|
-
|
|
153
|
-
|
|
97
|
+
d = data(req.variables, {
|
|
98
|
+
req,
|
|
99
|
+
ctx: newCtx
|
|
100
|
+
});
|
|
154
101
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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 });
|
|
102
|
+
return (responseEnhancer ? res[responseEnhancer] : res)(
|
|
103
|
+
ctx.data(d),
|
|
104
|
+
...responseTransforms
|
|
105
|
+
);
|
|
173
106
|
};
|
|
174
|
-
registerHandler(
|
|
175
|
-
import_msw.graphql[type](operation, resolver, {
|
|
176
|
-
once: responseEnhancer === "once"
|
|
177
|
-
})
|
|
178
|
-
);
|
|
107
|
+
registerHandler(import_msw.graphql[type](operation, resolver));
|
|
179
108
|
return data;
|
|
180
109
|
};
|
|
181
110
|
const mockGraphQLQuery = (operation, data, responseEnhancer) => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { cedarJsRouterImportTransformPlugin } from './vite-plugin-cedarjs-router-import-transform.js';
|
|
2
|
+
export { createAuthImportTransformPlugin } from './vite-plugin-create-auth-import-transform.js';
|
|
3
|
+
export { autoImportsPlugin } from './vite-plugin-auto-import.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,kDAAkD,CAAA;AACrG,OAAO,EAAE,+BAA+B,EAAE,MAAM,+CAA+C,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA"}
|
|
@@ -20,18 +20,15 @@ var vitest_exports = {};
|
|
|
20
20
|
__export(vitest_exports, {
|
|
21
21
|
autoImportsPlugin: () => import_vite_plugin_auto_import.autoImportsPlugin,
|
|
22
22
|
cedarJsRouterImportTransformPlugin: () => import_vite_plugin_cedarjs_router_import_transform.cedarJsRouterImportTransformPlugin,
|
|
23
|
-
cedarVitestWebConfigPlugin: () => import_vite_plugin_cedar_vitest_web_config.cedarVitestWebConfigPlugin,
|
|
24
23
|
createAuthImportTransformPlugin: () => import_vite_plugin_create_auth_import_transform.createAuthImportTransformPlugin
|
|
25
24
|
});
|
|
26
25
|
module.exports = __toCommonJS(vitest_exports);
|
|
27
26
|
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
27
|
var import_vite_plugin_create_auth_import_transform = require("./vite-plugin-create-auth-import-transform.js");
|
|
30
28
|
var import_vite_plugin_auto_import = require("./vite-plugin-auto-import.js");
|
|
31
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
30
|
0 && (module.exports = {
|
|
33
31
|
autoImportsPlugin,
|
|
34
32
|
cedarJsRouterImportTransformPlugin,
|
|
35
|
-
cedarVitestWebConfigPlugin,
|
|
36
33
|
createAuthImportTransformPlugin
|
|
37
34
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-auto-import.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/vite-plugin-auto-import.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,oJAsBhC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PluginOption } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Replace `@cedarjs/router` imports with imports of
|
|
4
|
+
* `@cedarjs/testing/web/MockRouter.js` instead
|
|
5
|
+
*/
|
|
6
|
+
export declare function cedarJsRouterImportTransformPlugin(): PluginOption;
|
|
7
|
+
//# sourceMappingURL=vite-plugin-cedarjs-router-import-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-cedarjs-router-import-transform.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/vite-plugin-cedarjs-router-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC;;;GAGG;AACH,wBAAgB,kCAAkC,IAAI,YAAY,CAejE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin-create-auth-import-transform.d.ts","sourceRoot":"","sources":["../../../../src/web/vitest/vite-plugin-create-auth-import-transform.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,wBAAgB,+BAA+B,IAAI,YAAY,CAuB9D"}
|
|
@@ -1 +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;
|
|
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;AAS9B,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"}
|
|
@@ -3,7 +3,9 @@ import {
|
|
|
3
3
|
getApiSideBabelPresets,
|
|
4
4
|
getApiSideBabelPlugins
|
|
5
5
|
} from "@cedarjs/babel-config";
|
|
6
|
-
const { babelrc: _b, ...defaultBabelConfig } = getApiSideDefaultBabelConfig(
|
|
6
|
+
const { babelrc: _b, ...defaultBabelConfig } = getApiSideDefaultBabelConfig({
|
|
7
|
+
forJest: true
|
|
8
|
+
});
|
|
7
9
|
const config = {
|
|
8
10
|
...defaultBabelConfig,
|
|
9
11
|
plugins: getApiSideBabelPlugins(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"globalSetup.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/api/globalSetup.ts"],"names":[],"mappings":"AAEA,OAAO,wBAAwB,CAAA;AAM/B,0CA2BC"}
|
|
@@ -3,25 +3,13 @@ import "dotenv-defaults/config";
|
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
6
|
-
import {
|
|
7
|
-
checkTestDatabaseUrlMatchesProvider,
|
|
8
|
-
redactDatabaseUrl
|
|
9
|
-
} from "../../../api/checkTestDatabase.js";
|
|
10
6
|
async function globalSetup_default() {
|
|
11
7
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
10
|
const cedarPaths = getPaths();
|
|
15
11
|
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
16
|
-
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
17
12
|
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
13
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
26
14
|
const pm = getPackageManager();
|
|
27
15
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
4
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
-
} catch (e) {
|
|
6
|
-
throw mod = 0, e;
|
|
7
|
-
}
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
4
|
};
|
|
9
5
|
import * as jestPreset from "./jest-preset.js";
|
|
10
6
|
var require_api = __commonJS({
|
|
@@ -1 +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;
|
|
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;AASlC,QAAA,MAAM,MAAM,EAAE,MA0Db,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -2,17 +2,8 @@ import path from "node:path";
|
|
|
2
2
|
import { getApiSideDefaultBabelConfig } from "@cedarjs/babel-config";
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
4
|
const rwjsPaths = getPaths();
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
return require.resolve(specifier, {
|
|
9
|
-
paths: [rwjsPaths.api.base, rwjsPaths.base]
|
|
10
|
-
});
|
|
11
|
-
} catch {
|
|
12
|
-
return void 0;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
const testingApiPath = resolveSubpath("@cedarjs/testing/api");
|
|
5
|
+
const NODE_MODULES_PATH = path.join(rwjsPaths.base, "node_modules");
|
|
6
|
+
const { babelrc } = getApiSideDefaultBabelConfig({ forJest: true });
|
|
16
7
|
const config = {
|
|
17
8
|
// To make sure other config option which depends on rootDir use
|
|
18
9
|
// correct path, for example, coverageDirectory
|
|
@@ -53,34 +44,11 @@ const config = {
|
|
|
53
44
|
"^src/(.*)$": path.join(rwjsPaths.api.src, "$1"),
|
|
54
45
|
// @NOTE: Import @cedarjs/testing in api tests, and it automatically remaps to the api side only
|
|
55
46
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
56
|
-
|
|
47
|
+
"^@cedarjs/testing$": path.join(NODE_MODULES_PATH, "@cedarjs/testing/api"),
|
|
57
48
|
// Support for importing files with extensions (like you'd do in ESM projects)
|
|
58
49
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
59
50
|
},
|
|
60
51
|
transform: {
|
|
61
|
-
// `@cedarjs/context`, `@cedarjs/api`, `@cedarjs/graphql-server`, and
|
|
62
|
-
// `@cedarjs/storage` are ESM-only. Two things pull them in at the top
|
|
63
|
-
// level of a generated project's api-side test run: @cedarjs/testing's
|
|
64
|
-
// own api entry point (which virtually every test imports, for
|
|
65
|
-
// scenario/mock helpers — pulls in `@cedarjs/context` and
|
|
66
|
-
// `@cedarjs/graphql-server` via `directive.ts`, and
|
|
67
|
-
// `@cedarjs/api/webhooks` via `apiFunction.ts`), and the *user's own*
|
|
68
|
-
// generated code — the `cedar setup uploads` template imports
|
|
69
|
-
// `@cedarjs/storage`. Jest's CJS runtime can't parse the real ESM these
|
|
70
|
-
// now emit, so they need the same babel-jest carve-out the web preset
|
|
71
|
-
// already uses for ESM-only node_modules packages (see jest-preset.ts
|
|
72
|
-
// on the web side for the fuller explanation of why this is
|
|
73
|
-
// necessary).
|
|
74
|
-
"[/\\\\]node_modules[/\\\\]@cedarjs[/\\\\](context|api|graphql-server|storage)[/\\\\].+\\.js$": [
|
|
75
|
-
"babel-jest",
|
|
76
|
-
{
|
|
77
|
-
babelrc: false,
|
|
78
|
-
configFile: false,
|
|
79
|
-
presets: [
|
|
80
|
-
[require.resolve("@babel/preset-env"), { targets: { node: "20" } }]
|
|
81
|
-
]
|
|
82
|
-
}
|
|
83
|
-
],
|
|
84
52
|
"\\.[cm]?[jt]sx?$": [
|
|
85
53
|
"babel-jest",
|
|
86
54
|
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
@@ -94,9 +62,6 @@ const config = {
|
|
|
94
62
|
}
|
|
95
63
|
]
|
|
96
64
|
},
|
|
97
|
-
transformIgnorePatterns: [
|
|
98
|
-
"[/\\\\]node_modules[/\\\\](?!@cedarjs[/\\\\]context[/\\\\])(?!@cedarjs[/\\\\]api[/\\\\])(?!@cedarjs[/\\\\]graphql-server[/\\\\])(?!@cedarjs[/\\\\]storage[/\\\\])"
|
|
99
|
-
],
|
|
100
65
|
testPathIgnorePatterns: [".scenarios.[jt]s$"]
|
|
101
66
|
};
|
|
102
67
|
var jest_preset_default = config;
|
|
@@ -1 +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;
|
|
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"}
|
|
@@ -2,7 +2,6 @@ import { parse } from "node:path";
|
|
|
2
2
|
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
3
3
|
"beforeQuery",
|
|
4
4
|
"QUERY",
|
|
5
|
-
"FRAGMENT",
|
|
6
5
|
"data",
|
|
7
6
|
"isEmpty",
|
|
8
7
|
"afterQuery",
|
|
@@ -48,7 +47,7 @@ function babel_plugin_redwood_cell_default({
|
|
|
48
47
|
state.hasDefaultExport = false;
|
|
49
48
|
},
|
|
50
49
|
exit(path, state) {
|
|
51
|
-
const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("
|
|
50
|
+
const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("data");
|
|
52
51
|
if (state.hasDefaultExport || !hasQueryOrDataExport) {
|
|
53
52
|
return;
|
|
54
53
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
4
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
-
} catch (e) {
|
|
6
|
-
throw mod = 0, e;
|
|
7
|
-
}
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
4
|
};
|
|
9
5
|
import jestRunner from "jest-runner";
|
|
10
6
|
var require_jest_serial_runner = __commonJS({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare class RedwoodWebJestEnvironment extends
|
|
1
|
+
import { TestEnvironment } from 'jest-environment-jsdom';
|
|
2
|
+
declare class RedwoodWebJestEnvironment extends TestEnvironment {
|
|
3
3
|
setup(): Promise<void>;
|
|
4
4
|
}
|
|
5
5
|
export default RedwoodWebJestEnvironment;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RedwoodWebJestEnv.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/RedwoodWebJestEnv.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { TextEncoder, TextDecoder } from "node:util";
|
|
2
|
+
import { TestEnvironment } from "jest-environment-jsdom";
|
|
3
|
+
class RedwoodWebJestEnvironment extends TestEnvironment {
|
|
3
4
|
async setup() {
|
|
4
5
|
await super.setup();
|
|
6
|
+
if (typeof this.global.TextEncoder === "undefined") {
|
|
7
|
+
this.global.TextEncoder = TextEncoder;
|
|
8
|
+
this.global.TextDecoder = TextDecoder;
|
|
9
|
+
}
|
|
5
10
|
if (typeof this.global.crypto.subtle === "undefined") {
|
|
6
11
|
this.global.crypto.subtle = {};
|
|
7
12
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
4
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
5
|
-
} catch (e) {
|
|
6
|
-
throw mod = 0, e;
|
|
7
|
-
}
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
8
4
|
};
|
|
9
5
|
import * as jestPreset from "./jest-preset.js";
|
|
10
6
|
var require_web = __commonJS({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest-preset.d.ts","sourceRoot":"","sources":["../../../../src/config/jest/web/jest-preset.ts"],"names":[],"mappings":"
|
|
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,MAkFb,CAAA;AAED,eAAe,MAAM,CAAA"}
|