@cedarjs/testing 4.2.1-next.0 → 4.2.1-next.269
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 +4 -1
- package/config/jest/api/jest-preset.js +1 -1
- package/config/jest/web/jest-preset.js +9 -9
- package/dist/api/vitest/CedarApiVitestEnv.d.ts.map +1 -1
- package/dist/api/vitest/CedarApiVitestEnv.js +4 -1
- package/dist/cjs/api/vitest/CedarApiVitestEnv.js +4 -1
- 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 +4 -1
- package/dist/cjs/config/jest/api/jest-preset.js +1 -1
- package/dist/cjs/config/jest/web/jest-preset.js +9 -9
- package/dist/cjs/web/MockProviders.js +2 -2
- package/dist/cjs/web/mockRequests.js +2 -2
- 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 +4 -1
- package/dist/config/jest/api/jest-preset.js +1 -1
- package/dist/config/jest/web/jest-preset.js +9 -9
- package/dist/web/MockProviders.js +2 -2
- package/dist/web/mockRequests.js +2 -2
- package/package.json +15 -15
|
@@ -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"}
|
|
@@ -22,7 +22,9 @@ __export(apiBabelConfig_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(apiBabelConfig_exports);
|
|
24
24
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
25
|
-
const { babelrc: _b, ...defaultBabelConfig } = (0, import_babel_config.getApiSideDefaultBabelConfig)(
|
|
25
|
+
const { babelrc: _b, ...defaultBabelConfig } = (0, import_babel_config.getApiSideDefaultBabelConfig)({
|
|
26
|
+
forJest: true
|
|
27
|
+
});
|
|
26
28
|
const config = {
|
|
27
29
|
...defaultBabelConfig,
|
|
28
30
|
plugins: (0, import_babel_config.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"}
|
|
@@ -35,6 +35,7 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
35
35
|
var import_config = require("dotenv-defaults/config");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
38
39
|
async function globalSetup_default() {
|
|
39
40
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
40
41
|
return;
|
|
@@ -43,7 +44,9 @@ async function globalSetup_default() {
|
|
|
43
44
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
44
45
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
45
46
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
46
|
-
|
|
47
|
+
const pm = (0, import_packageManager.getPackageManager)();
|
|
48
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
49
|
+
import_execa.default.sync(pmExec, ["cedar", ...command], {
|
|
47
50
|
cwd: cedarPaths.api.base,
|
|
48
51
|
stdio: "inherit",
|
|
49
52
|
env: process.env
|
|
@@ -36,7 +36,7 @@ var import_babel_config = require("@cedarjs/babel-config");
|
|
|
36
36
|
var import_project_config = require("@cedarjs/project-config");
|
|
37
37
|
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
38
38
|
const NODE_MODULES_PATH = import_node_path.default.join(rwjsPaths.base, "node_modules");
|
|
39
|
-
const { babelrc } = (0, import_babel_config.getApiSideDefaultBabelConfig)();
|
|
39
|
+
const { babelrc } = (0, import_babel_config.getApiSideDefaultBabelConfig)({ forJest: true });
|
|
40
40
|
const config = {
|
|
41
41
|
// To make sure other config option which depends on rootDir use
|
|
42
42
|
// correct path, for example, coverageDirectory
|
|
@@ -33,20 +33,20 @@ __export(jest_preset_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(jest_preset_exports);
|
|
34
34
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
35
|
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
-
const
|
|
37
|
-
const NODE_MODULES_PATH = import_node_path.default.join(
|
|
36
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
37
|
+
const NODE_MODULES_PATH = import_node_path.default.join(cedarPaths.base, "node_modules");
|
|
38
38
|
const config = {
|
|
39
39
|
// To make sure other config option which depends on rootDir always
|
|
40
40
|
// use correct path, for example, coverageDirectory
|
|
41
|
-
rootDir:
|
|
42
|
-
roots: [import_node_path.default.join(
|
|
41
|
+
rootDir: cedarPaths.base,
|
|
42
|
+
roots: [import_node_path.default.join(cedarPaths.web.src)],
|
|
43
43
|
testEnvironment: import_node_path.default.join(__dirname, "./RedwoodWebJestEnv.js"),
|
|
44
44
|
displayName: {
|
|
45
45
|
color: "blueBright",
|
|
46
46
|
name: "web"
|
|
47
47
|
},
|
|
48
48
|
globals: {
|
|
49
|
-
__RWJS_TESTROOT_DIR: import_node_path.default.join(
|
|
49
|
+
__RWJS_TESTROOT_DIR: import_node_path.default.join(cedarPaths.web.src),
|
|
50
50
|
// used in jest setup to load mocks
|
|
51
51
|
RWJS_ENV: {
|
|
52
52
|
RWJS_API_URL: "",
|
|
@@ -54,7 +54,7 @@ const config = {
|
|
|
54
54
|
__REDWOOD__APP_TITLE: "Redwood App"
|
|
55
55
|
},
|
|
56
56
|
RWJS_DEBUG_ENV: {
|
|
57
|
-
RWJS_SRC_ROOT:
|
|
57
|
+
RWJS_SRC_ROOT: cedarPaths.web.src
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
collectCoverageFrom: [
|
|
@@ -62,7 +62,7 @@ const config = {
|
|
|
62
62
|
"!**/node_modules/**",
|
|
63
63
|
"!**/dist/**"
|
|
64
64
|
],
|
|
65
|
-
coverageDirectory: import_node_path.default.join(
|
|
65
|
+
coverageDirectory: import_node_path.default.join(cedarPaths.base, "coverage"),
|
|
66
66
|
watchPlugins: [
|
|
67
67
|
"jest-watch-typeahead/filename",
|
|
68
68
|
"jest-watch-typeahead/testname"
|
|
@@ -94,8 +94,8 @@ const config = {
|
|
|
94
94
|
// @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
|
|
95
95
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
96
96
|
"^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
|
|
97
|
-
"~
|
|
98
|
-
"~
|
|
97
|
+
"~__CEDAR__USER_ROUTES_FOR_MOCK": cedarPaths.web.routes,
|
|
98
|
+
"~__CEDAR__USER_AUTH_FOR_MOCK": import_node_path.default.join(cedarPaths.web.src, "auth"),
|
|
99
99
|
/**
|
|
100
100
|
* Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
|
|
101
101
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CedarApiVitestEnv.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/CedarApiVitestEnv.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"CedarApiVitestEnv.d.ts","sourceRoot":"","sources":["../../../src/api/vitest/CedarApiVitestEnv.ts"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA;AAElC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAKtD,QAAA,MAAM,yBAAyB,EAAE,WAsChC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import "dotenv-defaults/config.js";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
5
6
|
const CedarApiVitestEnvironment = {
|
|
6
7
|
name: "cedar-api",
|
|
7
8
|
transformMode: "ssr",
|
|
@@ -16,7 +17,9 @@ const CedarApiVitestEnvironment = {
|
|
|
16
17
|
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
17
18
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
18
19
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
19
|
-
|
|
20
|
+
const pm = getPackageManager();
|
|
21
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
22
|
+
execa.sync(pmExec, ["cedar", ...command], {
|
|
20
23
|
cwd: cedarPaths.api.base,
|
|
21
24
|
stdio: "inherit",
|
|
22
25
|
env: process.env
|
|
@@ -35,6 +35,7 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
35
35
|
var import_config = require("dotenv-defaults/config.js");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
38
39
|
const CedarApiVitestEnvironment = {
|
|
39
40
|
name: "cedar-api",
|
|
40
41
|
transformMode: "ssr",
|
|
@@ -49,7 +50,9 @@ const CedarApiVitestEnvironment = {
|
|
|
49
50
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
50
51
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
51
52
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
52
|
-
|
|
53
|
+
const pm = (0, import_packageManager.getPackageManager)();
|
|
54
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
55
|
+
import_execa.default.sync(pmExec, ["cedar", ...command], {
|
|
53
56
|
cwd: cedarPaths.api.base,
|
|
54
57
|
stdio: "inherit",
|
|
55
58
|
env: process.env
|
|
@@ -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"}
|
|
@@ -22,7 +22,9 @@ __export(apiBabelConfig_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(apiBabelConfig_exports);
|
|
24
24
|
var import_babel_config = require("@cedarjs/babel-config");
|
|
25
|
-
const { babelrc: _b, ...defaultBabelConfig } = (0, import_babel_config.getApiSideDefaultBabelConfig)(
|
|
25
|
+
const { babelrc: _b, ...defaultBabelConfig } = (0, import_babel_config.getApiSideDefaultBabelConfig)({
|
|
26
|
+
forJest: true
|
|
27
|
+
});
|
|
26
28
|
const config = {
|
|
27
29
|
...defaultBabelConfig,
|
|
28
30
|
plugins: (0, import_babel_config.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"}
|
|
@@ -35,6 +35,7 @@ var import_node_path = __toESM(require("node:path"), 1);
|
|
|
35
35
|
var import_config = require("dotenv-defaults/config");
|
|
36
36
|
var import_execa = __toESM(require("execa"), 1);
|
|
37
37
|
var import_project_config = require("@cedarjs/project-config");
|
|
38
|
+
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
38
39
|
async function globalSetup_default() {
|
|
39
40
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
40
41
|
return;
|
|
@@ -43,7 +44,9 @@ async function globalSetup_default() {
|
|
|
43
44
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
44
45
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
45
46
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
46
|
-
|
|
47
|
+
const pm = (0, import_packageManager.getPackageManager)();
|
|
48
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
49
|
+
import_execa.default.sync(pmExec, ["cedar", ...command], {
|
|
47
50
|
cwd: cedarPaths.api.base,
|
|
48
51
|
stdio: "inherit",
|
|
49
52
|
env: process.env
|
|
@@ -36,7 +36,7 @@ var import_babel_config = require("@cedarjs/babel-config");
|
|
|
36
36
|
var import_project_config = require("@cedarjs/project-config");
|
|
37
37
|
const rwjsPaths = (0, import_project_config.getPaths)();
|
|
38
38
|
const NODE_MODULES_PATH = import_node_path.default.join(rwjsPaths.base, "node_modules");
|
|
39
|
-
const { babelrc } = (0, import_babel_config.getApiSideDefaultBabelConfig)();
|
|
39
|
+
const { babelrc } = (0, import_babel_config.getApiSideDefaultBabelConfig)({ forJest: true });
|
|
40
40
|
const config = {
|
|
41
41
|
// To make sure other config option which depends on rootDir use
|
|
42
42
|
// correct path, for example, coverageDirectory
|
|
@@ -33,20 +33,20 @@ __export(jest_preset_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(jest_preset_exports);
|
|
34
34
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
35
35
|
var import_project_config = require("@cedarjs/project-config");
|
|
36
|
-
const
|
|
37
|
-
const NODE_MODULES_PATH = import_node_path.default.join(
|
|
36
|
+
const cedarPaths = (0, import_project_config.getPaths)();
|
|
37
|
+
const NODE_MODULES_PATH = import_node_path.default.join(cedarPaths.base, "node_modules");
|
|
38
38
|
const config = {
|
|
39
39
|
// To make sure other config option which depends on rootDir always
|
|
40
40
|
// use correct path, for example, coverageDirectory
|
|
41
|
-
rootDir:
|
|
42
|
-
roots: [import_node_path.default.join(
|
|
41
|
+
rootDir: cedarPaths.base,
|
|
42
|
+
roots: [import_node_path.default.join(cedarPaths.web.src)],
|
|
43
43
|
testEnvironment: import_node_path.default.join(__dirname, "./RedwoodWebJestEnv.js"),
|
|
44
44
|
displayName: {
|
|
45
45
|
color: "blueBright",
|
|
46
46
|
name: "web"
|
|
47
47
|
},
|
|
48
48
|
globals: {
|
|
49
|
-
__RWJS_TESTROOT_DIR: import_node_path.default.join(
|
|
49
|
+
__RWJS_TESTROOT_DIR: import_node_path.default.join(cedarPaths.web.src),
|
|
50
50
|
// used in jest setup to load mocks
|
|
51
51
|
RWJS_ENV: {
|
|
52
52
|
RWJS_API_URL: "",
|
|
@@ -54,7 +54,7 @@ const config = {
|
|
|
54
54
|
__REDWOOD__APP_TITLE: "Redwood App"
|
|
55
55
|
},
|
|
56
56
|
RWJS_DEBUG_ENV: {
|
|
57
|
-
RWJS_SRC_ROOT:
|
|
57
|
+
RWJS_SRC_ROOT: cedarPaths.web.src
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
60
|
collectCoverageFrom: [
|
|
@@ -62,7 +62,7 @@ const config = {
|
|
|
62
62
|
"!**/node_modules/**",
|
|
63
63
|
"!**/dist/**"
|
|
64
64
|
],
|
|
65
|
-
coverageDirectory: import_node_path.default.join(
|
|
65
|
+
coverageDirectory: import_node_path.default.join(cedarPaths.base, "coverage"),
|
|
66
66
|
watchPlugins: [
|
|
67
67
|
"jest-watch-typeahead/filename",
|
|
68
68
|
"jest-watch-typeahead/testname"
|
|
@@ -94,8 +94,8 @@ const config = {
|
|
|
94
94
|
// @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
|
|
95
95
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
96
96
|
"^@cedarjs/testing$": import_node_path.default.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
|
|
97
|
-
"~
|
|
98
|
-
"~
|
|
97
|
+
"~__CEDAR__USER_ROUTES_FOR_MOCK": cedarPaths.web.routes,
|
|
98
|
+
"~__CEDAR__USER_AUTH_FOR_MOCK": import_node_path.default.join(cedarPaths.web.src, "auth"),
|
|
99
99
|
/**
|
|
100
100
|
* Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
|
|
101
101
|
*/
|
|
@@ -40,10 +40,10 @@ var import_mockAuth = require("./mockAuth.js");
|
|
|
40
40
|
var import_MockParamsProvider = require("./MockParamsProvider.js");
|
|
41
41
|
let UserRoutes;
|
|
42
42
|
try {
|
|
43
|
-
const userRoutesModule = require("~
|
|
43
|
+
const userRoutesModule = require("~__CEDAR__USER_ROUTES_FOR_MOCK");
|
|
44
44
|
UserRoutes = userRoutesModule.default;
|
|
45
45
|
} catch (error) {
|
|
46
|
-
if (!isModuleNotFoundError(error, "~
|
|
46
|
+
if (!isModuleNotFoundError(error, "~__CEDAR__USER_ROUTES_FOR_MOCK")) {
|
|
47
47
|
console.warn(error);
|
|
48
48
|
}
|
|
49
49
|
UserRoutes = () => /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null);
|
|
@@ -118,9 +118,9 @@ const mockedUserMeta = {
|
|
|
118
118
|
};
|
|
119
119
|
const mockCurrentUser = (user) => {
|
|
120
120
|
mockedUserMeta.currentUser = user;
|
|
121
|
-
mockGraphQLQuery("
|
|
121
|
+
mockGraphQLQuery("__CEDAR__AUTH_GET_CURRENT_USER", () => {
|
|
122
122
|
return {
|
|
123
|
-
|
|
123
|
+
cedar: {
|
|
124
124
|
currentUser: user
|
|
125
125
|
}
|
|
126
126
|
};
|
|
@@ -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"}
|
|
@@ -2,6 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import "dotenv-defaults/config";
|
|
3
3
|
import execa from "execa";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
|
+
import { getPackageManager } from "@cedarjs/project-config/packageManager";
|
|
5
6
|
async function globalSetup_default() {
|
|
6
7
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
7
8
|
return;
|
|
@@ -10,7 +11,9 @@ async function globalSetup_default() {
|
|
|
10
11
|
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
11
12
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
12
13
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
13
|
-
|
|
14
|
+
const pm = getPackageManager();
|
|
15
|
+
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
16
|
+
execa.sync(pmExec, ["cedar", ...command], {
|
|
14
17
|
cwd: cedarPaths.api.base,
|
|
15
18
|
stdio: "inherit",
|
|
16
19
|
env: process.env
|
|
@@ -3,7 +3,7 @@ import { getApiSideDefaultBabelConfig } from "@cedarjs/babel-config";
|
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
4
|
const rwjsPaths = getPaths();
|
|
5
5
|
const NODE_MODULES_PATH = path.join(rwjsPaths.base, "node_modules");
|
|
6
|
-
const { babelrc } = getApiSideDefaultBabelConfig();
|
|
6
|
+
const { babelrc } = getApiSideDefaultBabelConfig({ forJest: true });
|
|
7
7
|
const config = {
|
|
8
8
|
// To make sure other config option which depends on rootDir use
|
|
9
9
|
// correct path, for example, coverageDirectory
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { getPaths } from "@cedarjs/project-config";
|
|
3
|
-
const
|
|
4
|
-
const NODE_MODULES_PATH = path.join(
|
|
3
|
+
const cedarPaths = getPaths();
|
|
4
|
+
const NODE_MODULES_PATH = path.join(cedarPaths.base, "node_modules");
|
|
5
5
|
const config = {
|
|
6
6
|
// To make sure other config option which depends on rootDir always
|
|
7
7
|
// use correct path, for example, coverageDirectory
|
|
8
|
-
rootDir:
|
|
9
|
-
roots: [path.join(
|
|
8
|
+
rootDir: cedarPaths.base,
|
|
9
|
+
roots: [path.join(cedarPaths.web.src)],
|
|
10
10
|
testEnvironment: path.join(__dirname, "./RedwoodWebJestEnv.js"),
|
|
11
11
|
displayName: {
|
|
12
12
|
color: "blueBright",
|
|
13
13
|
name: "web"
|
|
14
14
|
},
|
|
15
15
|
globals: {
|
|
16
|
-
__RWJS_TESTROOT_DIR: path.join(
|
|
16
|
+
__RWJS_TESTROOT_DIR: path.join(cedarPaths.web.src),
|
|
17
17
|
// used in jest setup to load mocks
|
|
18
18
|
RWJS_ENV: {
|
|
19
19
|
RWJS_API_URL: "",
|
|
@@ -21,7 +21,7 @@ const config = {
|
|
|
21
21
|
__REDWOOD__APP_TITLE: "Redwood App"
|
|
22
22
|
},
|
|
23
23
|
RWJS_DEBUG_ENV: {
|
|
24
|
-
RWJS_SRC_ROOT:
|
|
24
|
+
RWJS_SRC_ROOT: cedarPaths.web.src
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
collectCoverageFrom: [
|
|
@@ -29,7 +29,7 @@ const config = {
|
|
|
29
29
|
"!**/node_modules/**",
|
|
30
30
|
"!**/dist/**"
|
|
31
31
|
],
|
|
32
|
-
coverageDirectory: path.join(
|
|
32
|
+
coverageDirectory: path.join(cedarPaths.base, "coverage"),
|
|
33
33
|
watchPlugins: [
|
|
34
34
|
"jest-watch-typeahead/filename",
|
|
35
35
|
"jest-watch-typeahead/testname"
|
|
@@ -61,8 +61,8 @@ const config = {
|
|
|
61
61
|
// @NOTE: Import @cedarjs/testing in web tests, and it automatically remaps to the web side only
|
|
62
62
|
// This is to prevent web stuff leaking into api, and vice versa
|
|
63
63
|
"^@cedarjs/testing$": path.join(NODE_MODULES_PATH, "@cedarjs/testing/web"),
|
|
64
|
-
"~
|
|
65
|
-
"~
|
|
64
|
+
"~__CEDAR__USER_ROUTES_FOR_MOCK": cedarPaths.web.routes,
|
|
65
|
+
"~__CEDAR__USER_AUTH_FOR_MOCK": path.join(cedarPaths.web.src, "auth"),
|
|
66
66
|
/**
|
|
67
67
|
* Mock out files that aren't particularly useful in tests. See fileMock.js for more info.
|
|
68
68
|
*/
|
|
@@ -7,10 +7,10 @@ import { useAuth } from "./mockAuth.js";
|
|
|
7
7
|
import { MockParamsProvider } from "./MockParamsProvider.js";
|
|
8
8
|
let UserRoutes;
|
|
9
9
|
try {
|
|
10
|
-
const userRoutesModule = require("~
|
|
10
|
+
const userRoutesModule = require("~__CEDAR__USER_ROUTES_FOR_MOCK");
|
|
11
11
|
UserRoutes = userRoutesModule.default;
|
|
12
12
|
} catch (error) {
|
|
13
|
-
if (!isModuleNotFoundError(error, "~
|
|
13
|
+
if (!isModuleNotFoundError(error, "~__CEDAR__USER_ROUTES_FOR_MOCK")) {
|
|
14
14
|
console.warn(error);
|
|
15
15
|
}
|
|
16
16
|
UserRoutes = () => /* @__PURE__ */ React.createElement(React.Fragment, null);
|
package/dist/web/mockRequests.js
CHANGED
|
@@ -78,9 +78,9 @@ const mockedUserMeta = {
|
|
|
78
78
|
};
|
|
79
79
|
const mockCurrentUser = (user) => {
|
|
80
80
|
mockedUserMeta.currentUser = user;
|
|
81
|
-
mockGraphQLQuery("
|
|
81
|
+
mockGraphQLQuery("__CEDAR__AUTH_GET_CURRENT_USER", () => {
|
|
82
82
|
return {
|
|
83
|
-
|
|
83
|
+
cedar: {
|
|
84
84
|
currentUser: user
|
|
85
85
|
}
|
|
86
86
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/testing",
|
|
3
|
-
"version": "4.2.1-next.
|
|
3
|
+
"version": "4.2.1-next.269",
|
|
4
4
|
"description": "Tools, wrappers and configuration for testing a Cedar project.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
"./dist/cjs/api/scenario.js": {
|
|
26
26
|
"default": "./dist/cjs/api/scenario.js"
|
|
27
27
|
},
|
|
28
|
-
"./dist/cjs/api/directUrlHelpers.js": {
|
|
29
|
-
"default": "./dist/cjs/api/directUrlHelpers.js"
|
|
30
|
-
},
|
|
31
28
|
"./dist/cjs/web/findCellMocks": {
|
|
32
29
|
"default": "./dist/cjs/web/findCellMocks.js"
|
|
33
30
|
},
|
|
@@ -107,29 +104,26 @@
|
|
|
107
104
|
"dist"
|
|
108
105
|
],
|
|
109
106
|
"scripts": {
|
|
110
|
-
"build": "
|
|
111
|
-
"build:pack": "
|
|
107
|
+
"build": "node ./build.mts && yarn build:types",
|
|
108
|
+
"build:pack": "yarn pack -o cedarjs-testing.tgz",
|
|
112
109
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
113
110
|
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
114
111
|
"build:watch": "nodemon --watch src --ext 'js,jsx,ts,tsx' --ignore dist --exec 'yarn build'",
|
|
115
|
-
"check:attw": "yarn
|
|
112
|
+
"check:attw": "yarn cedar-fwtools-attw",
|
|
116
113
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
117
114
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
118
115
|
"test": "vitest run",
|
|
119
116
|
"test:watch": "vitest watch"
|
|
120
117
|
},
|
|
121
118
|
"dependencies": {
|
|
122
|
-
"@cedarjs/auth": "4.2.0",
|
|
123
119
|
"@cedarjs/babel-config": "4.2.0",
|
|
124
120
|
"@cedarjs/context": "4.2.0",
|
|
125
121
|
"@cedarjs/graphql-server": "4.2.0",
|
|
126
122
|
"@cedarjs/project-config": "4.2.0",
|
|
127
|
-
"@cedarjs/router": "4.2.0",
|
|
128
|
-
"@cedarjs/web": "4.2.0",
|
|
129
123
|
"@testing-library/jest-dom": "6.9.1",
|
|
130
124
|
"@testing-library/react": "14.3.1",
|
|
131
125
|
"@testing-library/user-event": "14.6.1",
|
|
132
|
-
"@types/aws-lambda": "8.10.
|
|
126
|
+
"@types/aws-lambda": "8.10.162",
|
|
133
127
|
"@types/babel-core": "6.25.10",
|
|
134
128
|
"@types/jest": "29.5.14",
|
|
135
129
|
"@types/node": "24.10.4",
|
|
@@ -145,16 +139,22 @@
|
|
|
145
139
|
"whatwg-fetch": "3.6.20"
|
|
146
140
|
},
|
|
147
141
|
"devDependencies": {
|
|
142
|
+
"@arethetypeswrong/cli": "0.18.4",
|
|
143
|
+
"@cedarjs/auth": "4.2.0",
|
|
148
144
|
"@cedarjs/framework-tools": "4.2.0",
|
|
145
|
+
"@cedarjs/router": "4.2.0",
|
|
146
|
+
"@cedarjs/web": "4.2.0",
|
|
149
147
|
"concurrently": "9.2.1",
|
|
150
148
|
"jsdom": "27.4.0",
|
|
151
|
-
"publint": "0.3.
|
|
152
|
-
"tsx": "4.21.0",
|
|
149
|
+
"publint": "0.3.21",
|
|
153
150
|
"typescript": "5.9.3",
|
|
154
|
-
"vitest": "3.2.
|
|
151
|
+
"vitest": "3.2.6"
|
|
155
152
|
},
|
|
156
153
|
"peerDependencies": {
|
|
157
|
-
"
|
|
154
|
+
"@cedarjs/auth": "4.2.0",
|
|
155
|
+
"@cedarjs/router": "4.2.0",
|
|
156
|
+
"@cedarjs/web": "4.2.0",
|
|
157
|
+
"vitest": "3.2.6"
|
|
158
158
|
},
|
|
159
159
|
"peerDependenciesMeta": {
|
|
160
160
|
"vitest": {
|