@cedarjs/testing 5.0.6 → 5.0.7-next.219
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 +1 -3
- package/config/jest/api/globalSetup.d.ts.map +1 -1
- package/config/jest/api/globalSetup.js +9 -0
- package/config/jest/api/jest-preset.d.ts.map +1 -1
- package/config/jest/api/jest-preset.js +38 -3
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
- package/config/jest/babelPlugins/babel-plugin-redwood-cell.js +2 -1
- 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 +12 -7
- package/config/jest/web/jest-fixed-jsdom.d.js +1 -0
- package/config/jest/web/jest-preset.d.ts.map +1 -1
- package/config/jest/web/jest-preset.js +135 -30
- package/config/jest/web/jest.setup.d.ts +0 -1
- package/config/jest/web/jest.setup.d.ts.map +1 -1
- package/config/jest/web/jest.setup.js +0 -1
- package/dist/api/checkTestDatabase.d.ts +23 -0
- package/dist/api/checkTestDatabase.d.ts.map +1 -0
- package/dist/api/checkTestDatabase.js +44 -0
- package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
- package/dist/api/vitest/CedarApiVitestEnv.js +13 -1
- 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/checkTestDatabase.d.ts +23 -0
- package/dist/cjs/api/checkTestDatabase.d.ts.map +1 -0
- package/dist/cjs/api/checkTestDatabase.js +69 -0
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +10 -1
- 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 +1 -3
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/globalSetup.js +9 -0
- package/dist/cjs/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/jest-preset.js +38 -3
- 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 +2 -1
- 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 +12 -7
- package/dist/cjs/config/jest/web/jest-fixed-jsdom.d.js +1 -0
- package/dist/cjs/config/jest/web/jest-preset.d.ts.map +1 -1
- package/dist/cjs/config/jest/web/jest-preset.js +135 -30
- package/dist/cjs/config/jest/web/jest.setup.d.ts +0 -1
- package/dist/cjs/config/jest/web/jest.setup.d.ts.map +1 -1
- package/dist/cjs/config/jest/web/jest.setup.js +0 -1
- package/dist/cjs/web/MockProviders.js +9 -3
- package/dist/cjs/web/fileMock.d.ts +5 -4
- package/dist/cjs/web/fileMock.d.ts.map +1 -1
- package/dist/cjs/web/mockRequests.d.ts +60 -18
- package/dist/cjs/web/mockRequests.d.ts.map +1 -1
- package/dist/cjs/web/mockRequests.js +107 -36
- package/dist/cjs/web/vitest/index.js +3 -0
- package/dist/cjs/web/vitest/vite-plugin-cedar-vitest-web-config.js +51 -0
- package/dist/cjs/web/vitest/vitest-web.setup.js +19 -0
- package/dist/config/jest/api/apiBabelConfig.d.ts.map +1 -1
- package/dist/config/jest/api/apiBabelConfig.js +1 -3
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/config/jest/api/globalSetup.js +12 -0
- package/dist/config/jest/api/index.js +5 -1
- package/dist/config/jest/api/jest-preset.d.ts.map +1 -1
- package/dist/config/jest/api/jest-preset.js +38 -3
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.d.ts.map +1 -1
- package/dist/config/jest/babelPlugins/babel-plugin-redwood-cell.js +2 -1
- package/dist/config/jest/jest-serial-runner.js +5 -1
- 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 +2 -7
- package/dist/config/jest/web/index.js +5 -1
- package/dist/config/jest/web/jest-fixed-jsdom.d.js +0 -0
- package/dist/config/jest/web/jest-preset.d.ts.map +1 -1
- package/dist/config/jest/web/jest-preset.js +135 -30
- package/dist/config/jest/web/jest.setup.d.ts +0 -1
- package/dist/config/jest/web/jest.setup.d.ts.map +1 -1
- package/dist/config/jest/web/jest.setup.js +0 -1
- package/dist/config/jest/web/resolver.js +5 -1
- package/dist/web/MockProviders.js +9 -3
- package/dist/web/fileMock.d.ts +5 -4
- package/dist/web/fileMock.d.ts.map +1 -1
- package/dist/web/mockRequests.d.ts +60 -18
- package/dist/web/mockRequests.d.ts.map +1 -1
- package/dist/web/mockRequests.js +108 -37
- package/dist/web/vitest/index.d.ts +1 -0
- package/dist/web/vitest/index.d.ts.map +1 -1
- package/dist/web/vitest/index.js +2 -0
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts +12 -0
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.d.ts.map +1 -0
- package/dist/web/vitest/vite-plugin-cedar-vitest-web-config.js +16 -0
- 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/dist/web/vitest/vitest-web.setup.d.ts +2 -0
- package/dist/web/vitest/vitest-web.setup.d.ts.map +1 -0
- package/dist/web/vitest/vitest-web.setup.js +18 -0
- package/package.json +26 -21
- package/dist/cjs/web/vitest/index.d.ts +0 -4
- package/dist/cjs/web/vitest/index.d.ts.map +0 -1
- package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts +0 -2
- package/dist/cjs/web/vitest/vite-plugin-auto-import.d.ts.map +0 -1
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts +0 -7
- package/dist/cjs/web/vitest/vite-plugin-cedarjs-router-import-transform.d.ts.map +0 -1
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts +0 -3
- package/dist/cjs/web/vitest/vite-plugin-create-auth-import-transform.d.ts.map +0 -1
|
@@ -1,25 +1,67 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { RequestHandler, SharedOptions } from 'msw';
|
|
2
|
+
import type { StartOptions as StartMSWWorkerOptions } from 'msw/browser';
|
|
3
|
+
interface MockServerCommonApi {
|
|
4
|
+
use(...handlers: any[]): void;
|
|
5
|
+
resetHandlers(): void;
|
|
6
|
+
}
|
|
7
|
+
type MockWorkerInstance = MockServerCommonApi & {
|
|
8
|
+
stop(): void;
|
|
9
|
+
};
|
|
10
|
+
type MockServerInstance = MockServerCommonApi & {
|
|
11
|
+
listen(options?: Partial<SharedOptions>): void;
|
|
12
|
+
close(): void;
|
|
13
|
+
};
|
|
14
|
+
type StartOptions<Target> = Target extends 'browsers' ? StartMSWWorkerOptions : Partial<SharedOptions>;
|
|
15
|
+
export declare const startMSW: <Target extends "node" | "browsers">(target: Target, options?: StartOptions<Target>) => Promise<MockWorkerInstance | MockServerInstance>;
|
|
10
16
|
export declare const setupRequestHandlers: () => void;
|
|
11
17
|
export declare const closeServer: () => void;
|
|
12
18
|
export declare const registerHandler: (handler: RequestHandler) => void;
|
|
19
|
+
/**
|
|
20
|
+
* The `ctx` object passed to mock-data functions. It mirrors the API of MSW
|
|
21
|
+
* v1's GraphQL context so that existing Cedar mocks keep working with MSW v2,
|
|
22
|
+
* where the `(req, res, ctx)` resolver signature no longer exists.
|
|
23
|
+
*/
|
|
24
|
+
export interface MockGraphQLContext {
|
|
25
|
+
/** Set the http response status code (and optionally status text) */
|
|
26
|
+
status(code: number, text?: string): void;
|
|
27
|
+
/** Delay the response by the given number of milliseconds */
|
|
28
|
+
delay(durationMs: number): void;
|
|
29
|
+
/** Return GraphQL errors in the response */
|
|
30
|
+
errors(errorList: Record<string, unknown>[]): void;
|
|
31
|
+
/** Set a response header. Accepts a name/value pair or an object */
|
|
32
|
+
set(name: string | Record<string, string>, value?: string): void;
|
|
33
|
+
/** Set a response cookie */
|
|
34
|
+
cookie(name: string, value: string): void;
|
|
35
|
+
/** Set the `extensions` field of the GraphQL response */
|
|
36
|
+
extensions(extensions: Record<string, unknown>): void;
|
|
37
|
+
/** Set an arbitrary field on the GraphQL response body */
|
|
38
|
+
field(fieldName: string, value: unknown): void;
|
|
39
|
+
/** Set the `data` field of the response. Overrides the returned mock-data */
|
|
40
|
+
data(data: Record<string, unknown>): void;
|
|
41
|
+
/** Perform a request that bypasses any mock handlers */
|
|
42
|
+
fetch(input: string | URL | Request, init?: RequestInit): Promise<Response>;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Information about the intercepted GraphQL request, passed to mock-data
|
|
46
|
+
* functions as `req`
|
|
47
|
+
*/
|
|
48
|
+
export interface MockGraphQLRequest {
|
|
49
|
+
/** The intercepted Fetch API `Request` */
|
|
50
|
+
request: Request;
|
|
51
|
+
/** The GraphQL query document string */
|
|
52
|
+
query: string;
|
|
53
|
+
operationName: string;
|
|
54
|
+
variables: Record<string, any>;
|
|
55
|
+
cookies: Record<string, string>;
|
|
56
|
+
url: URL;
|
|
57
|
+
headers: Headers;
|
|
58
|
+
method: string;
|
|
59
|
+
}
|
|
13
60
|
export type DataFunction<Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>> = (variables: QueryVariables, { req, ctx, }: {
|
|
14
|
-
req:
|
|
15
|
-
ctx:
|
|
16
|
-
}) => Query | void
|
|
17
|
-
type
|
|
18
|
-
type ResponseEnhancers = {
|
|
19
|
-
once: ResponseFunction<any>;
|
|
20
|
-
networkError: (message: string) => void;
|
|
21
|
-
};
|
|
22
|
-
type ResponseEnhancer = keyof ResponseEnhancers;
|
|
61
|
+
req: MockGraphQLRequest;
|
|
62
|
+
ctx: MockGraphQLContext;
|
|
63
|
+
}) => Query | void | Promise<Query | void>;
|
|
64
|
+
type ResponseEnhancer = 'once' | 'networkError';
|
|
23
65
|
export declare const mockGraphQLQuery: <Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>>(operation: string, data: DataFunction<Query, QueryVariables> | Query, responseEnhancer?: ResponseEnhancer) => Record<string, any> | DataFunction<Record<string, unknown>, Record<string, any>>;
|
|
24
66
|
export declare const mockGraphQLMutation: <Query extends Record<string, unknown> = Record<string, unknown>, QueryVariables = Record<string, any>>(operation: string, data: DataFunction<Query, QueryVariables> | Query, responseEnhancer?: ResponseEnhancer) => Record<string, any> | DataFunction<Record<string, unknown>, Record<string, any>>;
|
|
25
67
|
export declare const mockedUserMeta: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mockRequests.d.ts","sourceRoot":"","sources":["../../../src/web/mockRequests.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mockRequests.d.ts","sourceRoot":"","sources":["../../../src/web/mockRequests.ts"],"names":[],"mappings":"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"}
|
|
@@ -41,28 +41,43 @@ 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";
|
|
44
45
|
const startMSW = async (target, options) => {
|
|
45
46
|
if (SERVER_INSTANCE) {
|
|
46
47
|
return SERVER_INSTANCE;
|
|
47
48
|
}
|
|
48
49
|
if (target === "browsers") {
|
|
49
|
-
|
|
50
|
-
|
|
50
|
+
const { setupWorker } = require("msw/browser");
|
|
51
|
+
const worker = setupWorker();
|
|
52
|
+
SERVER_INSTANCE = worker;
|
|
53
|
+
await worker.start(options);
|
|
51
54
|
} else {
|
|
52
|
-
const { setupServer } = require(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const { setupServer } = require(
|
|
56
|
+
/* @vite-ignore */
|
|
57
|
+
MSW_NODE_SPECIFIER
|
|
58
|
+
);
|
|
59
|
+
const server = setupServer();
|
|
60
|
+
SERVER_INSTANCE = server;
|
|
61
|
+
server.listen(options);
|
|
55
62
|
}
|
|
56
63
|
return SERVER_INSTANCE;
|
|
57
64
|
};
|
|
58
65
|
const setupRequestHandlers = () => {
|
|
59
|
-
SERVER_INSTANCE
|
|
66
|
+
SERVER_INSTANCE?.resetHandlers();
|
|
60
67
|
for (const handler of REQUEST_HANDLER_QUEUE) {
|
|
61
|
-
SERVER_INSTANCE
|
|
68
|
+
SERVER_INSTANCE?.use(handler);
|
|
62
69
|
}
|
|
63
70
|
};
|
|
64
71
|
const closeServer = () => {
|
|
65
|
-
SERVER_INSTANCE
|
|
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;
|
|
66
81
|
};
|
|
67
82
|
const registerHandler = (handler) => {
|
|
68
83
|
if (!SERVER_INSTANCE) {
|
|
@@ -72,39 +87,95 @@ const registerHandler = (handler) => {
|
|
|
72
87
|
}
|
|
73
88
|
};
|
|
74
89
|
const mockGraphQL = (type, operation, data, responseEnhancer) => {
|
|
75
|
-
const resolver = (
|
|
76
|
-
|
|
77
|
-
|
|
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();
|
|
78
106
|
if (typeof data === "function") {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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))
|
|
85
140
|
};
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
field: captureTransform(ctx.field)
|
|
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
|
|
96
150
|
};
|
|
97
|
-
d = data(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
});
|
|
151
|
+
d = await data(variables, { req, ctx });
|
|
152
|
+
} else {
|
|
153
|
+
d = data;
|
|
101
154
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
)
|
|
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 });
|
|
106
173
|
};
|
|
107
|
-
registerHandler(
|
|
174
|
+
registerHandler(
|
|
175
|
+
import_msw.graphql[type](operation, resolver, {
|
|
176
|
+
once: responseEnhancer === "once"
|
|
177
|
+
})
|
|
178
|
+
);
|
|
108
179
|
return data;
|
|
109
180
|
};
|
|
110
181
|
const mockGraphQLQuery = (operation, data, responseEnhancer) => {
|
|
@@ -20,15 +20,18 @@ 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,
|
|
23
24
|
createAuthImportTransformPlugin: () => import_vite_plugin_create_auth_import_transform.createAuthImportTransformPlugin
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(vitest_exports);
|
|
26
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");
|
|
27
29
|
var import_vite_plugin_create_auth_import_transform = require("./vite-plugin-create-auth-import-transform.js");
|
|
28
30
|
var import_vite_plugin_auto_import = require("./vite-plugin-auto-import.js");
|
|
29
31
|
// Annotate the CommonJS export names for ESM import in node:
|
|
30
32
|
0 && (module.exports = {
|
|
31
33
|
autoImportsPlugin,
|
|
32
34
|
cedarJsRouterImportTransformPlugin,
|
|
35
|
+
cedarVitestWebConfigPlugin,
|
|
33
36
|
createAuthImportTransformPlugin
|
|
34
37
|
});
|
|
@@ -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,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
|
+
});
|
|
@@ -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;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"}
|
|
@@ -3,9 +3,7 @@ import {
|
|
|
3
3
|
getApiSideBabelPresets,
|
|
4
4
|
getApiSideBabelPlugins
|
|
5
5
|
} from "@cedarjs/babel-config";
|
|
6
|
-
const { babelrc: _b, ...defaultBabelConfig } = getApiSideDefaultBabelConfig(
|
|
7
|
-
forJest: true
|
|
8
|
-
});
|
|
6
|
+
const { babelrc: _b, ...defaultBabelConfig } = getApiSideDefaultBabelConfig();
|
|
9
7
|
const config = {
|
|
10
8
|
...defaultBabelConfig,
|
|
11
9
|
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;AAW/B,0CAqCC"}
|
|
@@ -3,13 +3,25 @@ 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";
|
|
6
10
|
async function globalSetup_default() {
|
|
7
11
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
8
12
|
return;
|
|
9
13
|
}
|
|
10
14
|
const cedarPaths = getPaths();
|
|
11
15
|
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
16
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
12
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
|
+
);
|
|
13
25
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
14
26
|
const pm = getPackageManager();
|
|
15
27
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
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
|
+
}
|
|
4
8
|
};
|
|
5
9
|
import * as jestPreset from "./jest-preset.js";
|
|
6
10
|
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;AAkClC,QAAA,MAAM,MAAM,EAAE,MAqFb,CAAA;AAED,eAAe,MAAM,CAAA"}
|
|
@@ -2,8 +2,17 @@ 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
|
-
|
|
5
|
+
const { babelrc } = getApiSideDefaultBabelConfig();
|
|
6
|
+
function resolveSubpath(specifier) {
|
|
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");
|
|
7
16
|
const config = {
|
|
8
17
|
// To make sure other config option which depends on rootDir use
|
|
9
18
|
// correct path, for example, coverageDirectory
|
|
@@ -44,11 +53,34 @@ const config = {
|
|
|
44
53
|
"^src/(.*)$": path.join(rwjsPaths.api.src, "$1"),
|
|
45
54
|
// @NOTE: Import @cedarjs/testing in api tests, and it automatically remaps to the api side only
|
|
46
55
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
47
|
-
"^@cedarjs/testing$":
|
|
56
|
+
...testingApiPath ? { "^@cedarjs/testing$": testingApiPath } : {},
|
|
48
57
|
// Support for importing files with extensions (like you'd do in ESM projects)
|
|
49
58
|
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
50
59
|
},
|
|
51
60
|
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
|
+
],
|
|
52
84
|
"\\.[cm]?[jt]sx?$": [
|
|
53
85
|
"babel-jest",
|
|
54
86
|
// When jest runs tests in parallel, it serializes the config before passing down options to babel
|
|
@@ -62,6 +94,9 @@ const config = {
|
|
|
62
94
|
}
|
|
63
95
|
]
|
|
64
96
|
},
|
|
97
|
+
transformIgnorePatterns: [
|
|
98
|
+
"[/\\\\]node_modules[/\\\\](?!@cedarjs[/\\\\]context[/\\\\])(?!@cedarjs[/\\\\]api[/\\\\])(?!@cedarjs[/\\\\]graphql-server[/\\\\])(?!@cedarjs[/\\\\]storage[/\\\\])"
|
|
99
|
+
],
|
|
65
100
|
testPathIgnorePatterns: [".scenarios.[jt]s$"]
|
|
66
101
|
};
|
|
67
102
|
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;AAsCtC,UAAU,WAAY,SAAQ,UAAU;IAKtC,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,gBAAgB,EAAE,OAAO,CAAA;CAC1B;AAED,MAAM,CAAC,OAAO,WAAW,EACvB,KAAK,GACN,EAAE;IACD,KAAK,EAAE,OAAO,CAAC,CAAA;CAChB,GAAG,SAAS,CAAC,WAAW,CAAC,CAoHzB"}
|
|
@@ -2,6 +2,7 @@ import { parse } from "node:path";
|
|
|
2
2
|
const EXPECTED_EXPORTS_FROM_CELL = [
|
|
3
3
|
"beforeQuery",
|
|
4
4
|
"QUERY",
|
|
5
|
+
"FRAGMENT",
|
|
5
6
|
"data",
|
|
6
7
|
"isEmpty",
|
|
7
8
|
"afterQuery",
|
|
@@ -47,7 +48,7 @@ function babel_plugin_redwood_cell_default({
|
|
|
47
48
|
state.hasDefaultExport = false;
|
|
48
49
|
},
|
|
49
50
|
exit(path, state) {
|
|
50
|
-
const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("data");
|
|
51
|
+
const hasQueryOrDataExport = state.exportNames.includes("QUERY") || state.exportNames.includes("FRAGMENT") || state.exportNames.includes("data");
|
|
51
52
|
if (state.hasDefaultExport || !hasQueryOrDataExport) {
|
|
52
53
|
return;
|
|
53
54
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
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
|
+
}
|
|
4
8
|
};
|
|
5
9
|
import jestRunner from "jest-runner";
|
|
6
10
|
var require_jest_serial_runner = __commonJS({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
declare class RedwoodWebJestEnvironment extends
|
|
1
|
+
import JSDOMEnvironment from 'jest-fixed-jsdom';
|
|
2
|
+
declare class RedwoodWebJestEnvironment extends JSDOMEnvironment {
|
|
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":"AAAA,OAAO,gBAAgB,MAAM,kBAAkB,CAAA;AAkB/C,cAAM,yBAA0B,SAAQ,gBAAgB;IAChD,KAAK;CASZ;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class RedwoodWebJestEnvironment extends TestEnvironment {
|
|
1
|
+
import JSDOMEnvironment from "jest-fixed-jsdom";
|
|
2
|
+
class RedwoodWebJestEnvironment extends JSDOMEnvironment {
|
|
4
3
|
async setup() {
|
|
5
4
|
await super.setup();
|
|
6
|
-
if (typeof this.global.TextEncoder === "undefined") {
|
|
7
|
-
this.global.TextEncoder = TextEncoder;
|
|
8
|
-
this.global.TextDecoder = TextDecoder;
|
|
9
|
-
}
|
|
10
5
|
if (typeof this.global.crypto.subtle === "undefined") {
|
|
11
6
|
this.global.crypto.subtle = {};
|
|
12
7
|
}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
|
|
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
|
+
}
|
|
4
8
|
};
|
|
5
9
|
import * as jestPreset from "./jest-preset.js";
|
|
6
10
|
var require_web = __commonJS({
|
|
File without changes
|
|
@@ -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":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAiIlC,QAAA,MAAM,MAAM,EAAE,MA0Ib,CAAA;AAED,eAAe,MAAM,CAAA"}
|