@cedarjs/testing 5.0.4-next.167 → 5.0.4
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/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.js +1 -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/vitest/CedarApiVitestEnv.js +1 -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 +3 -1
- 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/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/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 +3 -9
- 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/package.json +21 -23
- package/config/jest/web/jest-fixed-jsdom.d.js +0 -1
- 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
package/dist/web/mockRequests.js
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { setupWorker, graphql } from "msw";
|
|
2
2
|
let REQUEST_HANDLER_QUEUE = [];
|
|
3
3
|
let SERVER_INSTANCE;
|
|
4
|
-
const MSW_NODE_SPECIFIER = "msw/node";
|
|
5
4
|
const startMSW = async (target, options) => {
|
|
6
5
|
if (SERVER_INSTANCE) {
|
|
7
6
|
return SERVER_INSTANCE;
|
|
8
7
|
}
|
|
9
8
|
if (target === "browsers") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
SERVER_INSTANCE = worker;
|
|
13
|
-
await worker.start(options);
|
|
9
|
+
SERVER_INSTANCE = setupWorker();
|
|
10
|
+
await SERVER_INSTANCE.start(options);
|
|
14
11
|
} else {
|
|
15
|
-
const { setupServer } = await import(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
);
|
|
19
|
-
const server = setupServer();
|
|
20
|
-
SERVER_INSTANCE = server;
|
|
21
|
-
server.listen(options);
|
|
12
|
+
const { setupServer } = await import("msw/node");
|
|
13
|
+
SERVER_INSTANCE = setupServer();
|
|
14
|
+
await SERVER_INSTANCE.listen(options);
|
|
22
15
|
}
|
|
23
16
|
return SERVER_INSTANCE;
|
|
24
17
|
};
|
|
25
18
|
const setupRequestHandlers = () => {
|
|
26
|
-
SERVER_INSTANCE
|
|
19
|
+
SERVER_INSTANCE.resetHandlers();
|
|
27
20
|
for (const handler of REQUEST_HANDLER_QUEUE) {
|
|
28
|
-
SERVER_INSTANCE
|
|
21
|
+
SERVER_INSTANCE.use(handler);
|
|
29
22
|
}
|
|
30
23
|
};
|
|
31
24
|
const closeServer = () => {
|
|
32
|
-
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if ("close" in SERVER_INSTANCE) {
|
|
36
|
-
SERVER_INSTANCE.close();
|
|
37
|
-
} else {
|
|
38
|
-
SERVER_INSTANCE.stop();
|
|
39
|
-
}
|
|
40
|
-
SERVER_INSTANCE = void 0;
|
|
25
|
+
SERVER_INSTANCE.close();
|
|
41
26
|
};
|
|
42
27
|
const registerHandler = (handler) => {
|
|
43
28
|
if (!SERVER_INSTANCE) {
|
|
@@ -47,95 +32,39 @@ const registerHandler = (handler) => {
|
|
|
47
32
|
}
|
|
48
33
|
};
|
|
49
34
|
const mockGraphQL = (type, operation, data, responseEnhancer) => {
|
|
50
|
-
const resolver =
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
operationName,
|
|
54
|
-
variables,
|
|
55
|
-
cookies
|
|
56
|
-
}) => {
|
|
57
|
-
let d = void 0;
|
|
58
|
-
let status = 200;
|
|
59
|
-
let statusText;
|
|
60
|
-
let delayDurationMs;
|
|
61
|
-
let errorList;
|
|
62
|
-
let extensions;
|
|
63
|
-
let explicitData;
|
|
64
|
-
const extraFields = {};
|
|
65
|
-
const headers = new Headers();
|
|
35
|
+
const resolver = (req, res, ctx) => {
|
|
36
|
+
let d = data;
|
|
37
|
+
let responseTransforms = [];
|
|
66
38
|
if (typeof data === "function") {
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
delayDurationMs = durationMs;
|
|
74
|
-
},
|
|
75
|
-
errors: (errors) => {
|
|
76
|
-
errorList = errors;
|
|
77
|
-
},
|
|
78
|
-
set: (name, value) => {
|
|
79
|
-
if (typeof name === "object") {
|
|
80
|
-
for (const [headerName, headerValue] of Object.entries(name)) {
|
|
81
|
-
headers.set(headerName, headerValue);
|
|
82
|
-
}
|
|
83
|
-
} else if (typeof value !== "undefined") {
|
|
84
|
-
headers.set(name, value);
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
cookie: (name, value) => {
|
|
88
|
-
headers.append("Set-Cookie", `${name}=${value}`);
|
|
89
|
-
},
|
|
90
|
-
extensions: (ext) => {
|
|
91
|
-
extensions = ext;
|
|
92
|
-
},
|
|
93
|
-
field: (fieldName, value) => {
|
|
94
|
-
extraFields[fieldName] = value;
|
|
95
|
-
},
|
|
96
|
-
data: (dataValue) => {
|
|
97
|
-
explicitData = dataValue;
|
|
98
|
-
},
|
|
99
|
-
fetch: (input, init) => fetch(bypass(input, init))
|
|
39
|
+
const captureTransform = (fn) => {
|
|
40
|
+
return (...args) => {
|
|
41
|
+
const resTransform = fn(...args);
|
|
42
|
+
responseTransforms = [...responseTransforms, resTransform];
|
|
43
|
+
return resTransform;
|
|
44
|
+
};
|
|
100
45
|
};
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
46
|
+
const newCtx = {
|
|
47
|
+
status: captureTransform(ctx.status),
|
|
48
|
+
delay: captureTransform(ctx.delay),
|
|
49
|
+
errors: captureTransform(ctx.errors),
|
|
50
|
+
set: captureTransform(ctx.set),
|
|
51
|
+
fetch: captureTransform(ctx.fetch),
|
|
52
|
+
data: captureTransform(ctx.data),
|
|
53
|
+
extensions: captureTransform(ctx.extensions),
|
|
54
|
+
cookie: captureTransform(ctx.cookie),
|
|
55
|
+
field: captureTransform(ctx.field)
|
|
110
56
|
};
|
|
111
|
-
d =
|
|
112
|
-
|
|
113
|
-
|
|
57
|
+
d = data(req.variables, {
|
|
58
|
+
req,
|
|
59
|
+
ctx: newCtx
|
|
60
|
+
});
|
|
114
61
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
await delay(delayDurationMs);
|
|
120
|
-
}
|
|
121
|
-
const body = { ...extraFields };
|
|
122
|
-
const bodyData = explicitData ?? d;
|
|
123
|
-
if (typeof bodyData !== "undefined") {
|
|
124
|
-
body.data = bodyData;
|
|
125
|
-
}
|
|
126
|
-
if (typeof errorList !== "undefined") {
|
|
127
|
-
body.errors = errorList;
|
|
128
|
-
}
|
|
129
|
-
if (typeof extensions !== "undefined") {
|
|
130
|
-
body.extensions = extensions;
|
|
131
|
-
}
|
|
132
|
-
return HttpResponse.json(body, { status, statusText, headers });
|
|
62
|
+
return (responseEnhancer ? res[responseEnhancer] : res)(
|
|
63
|
+
ctx.data(d),
|
|
64
|
+
...responseTransforms
|
|
65
|
+
);
|
|
133
66
|
};
|
|
134
|
-
registerHandler(
|
|
135
|
-
graphql[type](operation, resolver, {
|
|
136
|
-
once: responseEnhancer === "once"
|
|
137
|
-
})
|
|
138
|
-
);
|
|
67
|
+
registerHandler(graphql[type](operation, resolver));
|
|
139
68
|
return data;
|
|
140
69
|
};
|
|
141
70
|
const mockGraphQLQuery = (operation, data, responseEnhancer) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { cedarJsRouterImportTransformPlugin } from './vite-plugin-cedarjs-router-import-transform.js';
|
|
2
|
-
export { cedarVitestWebConfigPlugin } from './vite-plugin-cedar-vitest-web-config.js';
|
|
3
2
|
export { createAuthImportTransformPlugin } from './vite-plugin-create-auth-import-transform.js';
|
|
4
3
|
export { autoImportsPlugin } from './vite-plugin-auto-import.js';
|
|
5
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +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
|
|
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"}
|
package/dist/web/vitest/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { cedarJsRouterImportTransformPlugin } from "./vite-plugin-cedarjs-router-import-transform.js";
|
|
2
|
-
import { cedarVitestWebConfigPlugin } from "./vite-plugin-cedar-vitest-web-config.js";
|
|
3
2
|
import { createAuthImportTransformPlugin } from "./vite-plugin-create-auth-import-transform.js";
|
|
4
3
|
import { autoImportsPlugin } from "./vite-plugin-auto-import.js";
|
|
5
4
|
export {
|
|
6
5
|
autoImportsPlugin,
|
|
7
6
|
cedarJsRouterImportTransformPlugin,
|
|
8
|
-
cedarVitestWebConfigPlugin,
|
|
9
7
|
createAuthImportTransformPlugin
|
|
10
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/testing",
|
|
3
|
-
"version": "5.0.4
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"description": "Tools, wrappers and configuration for testing a Cedar project.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -116,47 +116,45 @@
|
|
|
116
116
|
"test:watch": "vitest watch"
|
|
117
117
|
},
|
|
118
118
|
"dependencies": {
|
|
119
|
-
"@babel
|
|
120
|
-
"@cedarjs/
|
|
121
|
-
"@cedarjs/
|
|
122
|
-
"@cedarjs/
|
|
123
|
-
"@cedarjs/project-config": "5.0.4-next.167",
|
|
124
|
-
"@testing-library/dom": "10.4.1",
|
|
119
|
+
"@cedarjs/babel-config": "5.0.4",
|
|
120
|
+
"@cedarjs/context": "5.0.4",
|
|
121
|
+
"@cedarjs/graphql-server": "5.0.4",
|
|
122
|
+
"@cedarjs/project-config": "5.0.4",
|
|
125
123
|
"@testing-library/jest-dom": "6.9.1",
|
|
126
|
-
"@testing-library/react": "
|
|
124
|
+
"@testing-library/react": "14.3.1",
|
|
127
125
|
"@testing-library/user-event": "14.6.1",
|
|
128
126
|
"@types/aws-lambda": "8.10.162",
|
|
129
127
|
"@types/babel-core": "6.25.10",
|
|
130
128
|
"@types/jest": "29.5.14",
|
|
131
129
|
"@types/node": "24.10.4",
|
|
132
|
-
"ansis": "4.
|
|
130
|
+
"ansis": "4.2.0",
|
|
133
131
|
"babel-jest": "^29.7.0",
|
|
134
132
|
"fast-glob": "3.3.3",
|
|
135
133
|
"jest": "29.7.0",
|
|
136
134
|
"jest-environment-jsdom": "29.7.0",
|
|
137
|
-
"jest-fixed-jsdom": "0.0.11",
|
|
138
135
|
"jest-watch-typeahead": "2.2.2",
|
|
139
|
-
"msw": "
|
|
136
|
+
"msw": "1.3.5",
|
|
140
137
|
"ts-toolbelt": "9.6.0",
|
|
141
|
-
"unplugin-auto-import": "19.3.0"
|
|
138
|
+
"unplugin-auto-import": "19.3.0",
|
|
139
|
+
"whatwg-fetch": "3.6.20"
|
|
142
140
|
},
|
|
143
141
|
"devDependencies": {
|
|
144
|
-
"@arethetypeswrong/cli": "0.18.
|
|
145
|
-
"@cedarjs/auth": "5.0.4
|
|
146
|
-
"@cedarjs/framework-tools": "5.0.4
|
|
147
|
-
"@cedarjs/router": "5.0.4
|
|
148
|
-
"@cedarjs/web": "5.0.4
|
|
142
|
+
"@arethetypeswrong/cli": "0.18.4",
|
|
143
|
+
"@cedarjs/auth": "5.0.4",
|
|
144
|
+
"@cedarjs/framework-tools": "5.0.4",
|
|
145
|
+
"@cedarjs/router": "5.0.4",
|
|
146
|
+
"@cedarjs/web": "5.0.4",
|
|
149
147
|
"concurrently": "9.2.4",
|
|
150
148
|
"jsdom": "27.4.0",
|
|
151
|
-
"publint": "0.3.
|
|
149
|
+
"publint": "0.3.21",
|
|
152
150
|
"typescript": "5.9.3",
|
|
153
|
-
"vitest": "
|
|
151
|
+
"vitest": "3.2.6"
|
|
154
152
|
},
|
|
155
153
|
"peerDependencies": {
|
|
156
|
-
"@cedarjs/auth": "5.0.4
|
|
157
|
-
"@cedarjs/router": "5.0.4
|
|
158
|
-
"@cedarjs/web": "5.0.4
|
|
159
|
-
"vitest": "
|
|
154
|
+
"@cedarjs/auth": "5.0.4",
|
|
155
|
+
"@cedarjs/router": "5.0.4",
|
|
156
|
+
"@cedarjs/web": "5.0.4",
|
|
157
|
+
"vitest": "3.2.6"
|
|
160
158
|
},
|
|
161
159
|
"peerDependenciesMeta": {
|
|
162
160
|
"vitest": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var 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
|
-
});
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
});
|
|
File without changes
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Contributes web-side Vitest config, most importantly a setup file that
|
|
4
|
-
* starts MSW so that `mockGraphQLQuery`/`mockGraphQLMutation` handlers (and
|
|
5
|
-
* cell mocks) actually intercept GraphQL requests during tests.
|
|
6
|
-
*
|
|
7
|
-
* Vitest resolves its `test` config from Vite plugins, so returning `test`
|
|
8
|
-
* from the `config` hook here merges with the user's own vitest config (the
|
|
9
|
-
* `setupFiles` arrays are concatenated).
|
|
10
|
-
*/
|
|
11
|
-
export declare function cedarVitestWebConfigPlugin(): Plugin;
|
|
12
|
-
//# sourceMappingURL=vite-plugin-cedar-vitest-web-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-cedar-vitest-web-config.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/vite-plugin-cedar-vitest-web-config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAKlC;;;;;;;;GAQG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAWnD"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
function cedarVitestWebConfigPlugin() {
|
|
3
|
-
return {
|
|
4
|
-
name: "cedar-vitest-web-config",
|
|
5
|
-
config: () => {
|
|
6
|
-
return {
|
|
7
|
-
test: {
|
|
8
|
-
setupFiles: [path.join(import.meta.dirname, "vitest-web.setup.js")]
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
cedarVitestWebConfigPlugin
|
|
16
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vitest-web.setup.d.ts","sourceRoot":"","sources":["../../../src/web/vitest/vitest-web.setup.ts"],"names":[],"mappings":""}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { afterAll, afterEach, beforeAll } from "vitest";
|
|
2
|
-
import { getPaths } from "@cedarjs/project-config";
|
|
3
|
-
import { findCellMocks } from "../findCellMocks.js";
|
|
4
|
-
import { closeServer, setupRequestHandlers, startMSW } from "../mockRequests.js";
|
|
5
|
-
beforeAll(async () => {
|
|
6
|
-
const cellMocks = findCellMocks(getPaths().web.src);
|
|
7
|
-
for (const m of cellMocks) {
|
|
8
|
-
await import(m);
|
|
9
|
-
}
|
|
10
|
-
await startMSW("node");
|
|
11
|
-
setupRequestHandlers();
|
|
12
|
-
});
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
setupRequestHandlers();
|
|
15
|
-
});
|
|
16
|
-
afterAll(() => {
|
|
17
|
-
closeServer();
|
|
18
|
-
});
|