@cedarjs/testing 5.0.7-next.186 → 5.0.7-next.239
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/globalSetup.d.ts.map +1 -1
- package/config/jest/api/globalSetup.js +9 -0
- 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 +12 -0
- 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 +9 -0
- package/dist/cjs/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/cjs/config/jest/api/globalSetup.js +9 -0
- package/dist/config/jest/api/globalSetup.d.ts.map +1 -1
- package/dist/config/jest/api/globalSetup.js +12 -0
- package/package.json +16 -13
|
@@ -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"}
|
|
@@ -36,13 +36,22 @@ 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
38
|
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
39
|
+
var import_checkTestDatabase = require("@cedarjs/testing/dist/cjs/api/checkTestDatabase.js");
|
|
39
40
|
async function globalSetup_default() {
|
|
40
41
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
const cedarPaths = (0, import_project_config.getPaths)();
|
|
44
45
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
46
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
45
47
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
48
|
+
await (0, import_checkTestDatabase.checkTestDatabaseUrlMatchesProvider)(
|
|
49
|
+
process.env.DATABASE_URL,
|
|
50
|
+
usedFallback
|
|
51
|
+
);
|
|
52
|
+
console.log(
|
|
53
|
+
`Setting up test database: ${(0, import_checkTestDatabase.redactDatabaseUrl)(process.env.DATABASE_URL)}`
|
|
54
|
+
);
|
|
46
55
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
47
56
|
const pm = (0, import_packageManager.getPackageManager)();
|
|
48
57
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redacts credentials from a database connection string so it's safe to
|
|
3
|
+
* print. Handles both URI-style authority credentials, e.g.
|
|
4
|
+
* `postgres://user:pass@host/db` -> `postgres://user:***@host/db`, and
|
|
5
|
+
* semicolon-delimited key/value credentials used by SQL Server connection
|
|
6
|
+
* strings, e.g. `Server=host;Password=secret;` -> `Server=host;Password=***;`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function redactDatabaseUrl(url: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Checks that the `DATABASE_URL` about to be used for tests matches the
|
|
11
|
+
* datasource provider configured in `schema.prisma`, and throws an
|
|
12
|
+
* actionable error if they don't match.
|
|
13
|
+
*
|
|
14
|
+
* Without this check, running `prisma db push`/`migrate reset` against a
|
|
15
|
+
* mismatched provider/URL combination (e.g. a leftover sqlite fallback URL
|
|
16
|
+
* with a `postgresql` schema) can hang indefinitely with no output, instead
|
|
17
|
+
* of failing fast. See https://github.com/cedarjs/cedar/issues/2284.
|
|
18
|
+
*
|
|
19
|
+
* If the provider can't be determined (e.g. `schema.prisma` doesn't exist
|
|
20
|
+
* yet), this is a no-op — Prisma itself will surface the problem.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkTestDatabaseUrlMatchesProvider(databaseUrl: string, usedFallback: boolean): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=checkTestDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTestDatabase.d.ts","sourceRoot":"","sources":["../../src/api/checkTestDatabase.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mCAAmC,CACvD,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,iBAmCtB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { getPrismaDatasourceProvider } from "@cedarjs/project-config";
|
|
2
|
+
const PROVIDER_URL_SCHEMES = {
|
|
3
|
+
sqlite: ["file:"],
|
|
4
|
+
postgresql: ["postgres:", "postgresql:"],
|
|
5
|
+
postgres: ["postgres:", "postgresql:"],
|
|
6
|
+
cockroachdb: ["postgres:", "postgresql:"],
|
|
7
|
+
mysql: ["mysql:"],
|
|
8
|
+
sqlserver: ["sqlserver:"],
|
|
9
|
+
mongodb: ["mongodb:", "mongodb+srv:"]
|
|
10
|
+
};
|
|
11
|
+
function getUrlScheme(url) {
|
|
12
|
+
const match = url.match(/^([a-z][a-z0-9+.-]*:)/i);
|
|
13
|
+
return match?.[1]?.toLowerCase();
|
|
14
|
+
}
|
|
15
|
+
function redactDatabaseUrl(url) {
|
|
16
|
+
return url.replace(/:\/\/([^:/?#]+):([^@/?#]+)@/, "://$1:***@").replace(/((?:^|;)\s*password\s*=)[^;]*/gi, "$1***");
|
|
17
|
+
}
|
|
18
|
+
async function checkTestDatabaseUrlMatchesProvider(databaseUrl, usedFallback) {
|
|
19
|
+
let provider;
|
|
20
|
+
try {
|
|
21
|
+
provider = await getPrismaDatasourceProvider();
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const expectedSchemes = PROVIDER_URL_SCHEMES[provider];
|
|
26
|
+
if (!expectedSchemes) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const actualScheme = getUrlScheme(databaseUrl);
|
|
30
|
+
if (actualScheme && expectedSchemes.includes(actualScheme)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const redactedUrl = redactDatabaseUrl(databaseUrl);
|
|
34
|
+
const reason = usedFallback ? `TEST_DATABASE_URL is not set, so the default sqlite test database was used (${redactedUrl}), but your schema.prisma is configured for "${provider}". Set TEST_DATABASE_URL to a "${provider}" connection string to run tests.` : `TEST_DATABASE_URL (${redactedUrl}) does not match the "${provider}" provider configured in schema.prisma. Update TEST_DATABASE_URL to a "${provider}" connection string.`;
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Test database URL does not match your Prisma schema's provider.
|
|
37
|
+
|
|
38
|
+
${reason}`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
checkTestDatabaseUrlMatchesProvider,
|
|
43
|
+
redactDatabaseUrl
|
|
44
|
+
};
|
|
@@ -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;AAUtD,QAAA,MAAM,yBAAyB,EAAE,WAgDhC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
|
|
@@ -3,6 +3,10 @@ import "dotenv-defaults/config.js";
|
|
|
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 "../checkTestDatabase.js";
|
|
6
10
|
const CedarApiVitestEnvironment = {
|
|
7
11
|
name: "cedar-api",
|
|
8
12
|
viteEnvironment: "ssr",
|
|
@@ -15,7 +19,15 @@ const CedarApiVitestEnvironment = {
|
|
|
15
19
|
}
|
|
16
20
|
const cedarPaths = getPaths();
|
|
17
21
|
const defaultDb = `file:${path.join(cedarPaths.generated.base, "test.db")}`;
|
|
22
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
18
23
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
24
|
+
await checkTestDatabaseUrlMatchesProvider(
|
|
25
|
+
process.env.DATABASE_URL,
|
|
26
|
+
usedFallback
|
|
27
|
+
);
|
|
28
|
+
console.log(
|
|
29
|
+
`Setting up test database: ${redactDatabaseUrl(process.env.DATABASE_URL)}`
|
|
30
|
+
);
|
|
19
31
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
20
32
|
const pm = getPackageManager();
|
|
21
33
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redacts credentials from a database connection string so it's safe to
|
|
3
|
+
* print. Handles both URI-style authority credentials, e.g.
|
|
4
|
+
* `postgres://user:pass@host/db` -> `postgres://user:***@host/db`, and
|
|
5
|
+
* semicolon-delimited key/value credentials used by SQL Server connection
|
|
6
|
+
* strings, e.g. `Server=host;Password=secret;` -> `Server=host;Password=***;`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function redactDatabaseUrl(url: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Checks that the `DATABASE_URL` about to be used for tests matches the
|
|
11
|
+
* datasource provider configured in `schema.prisma`, and throws an
|
|
12
|
+
* actionable error if they don't match.
|
|
13
|
+
*
|
|
14
|
+
* Without this check, running `prisma db push`/`migrate reset` against a
|
|
15
|
+
* mismatched provider/URL combination (e.g. a leftover sqlite fallback URL
|
|
16
|
+
* with a `postgresql` schema) can hang indefinitely with no output, instead
|
|
17
|
+
* of failing fast. See https://github.com/cedarjs/cedar/issues/2284.
|
|
18
|
+
*
|
|
19
|
+
* If the provider can't be determined (e.g. `schema.prisma` doesn't exist
|
|
20
|
+
* yet), this is a no-op — Prisma itself will surface the problem.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkTestDatabaseUrlMatchesProvider(databaseUrl: string, usedFallback: boolean): Promise<void>;
|
|
23
|
+
//# sourceMappingURL=checkTestDatabase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkTestDatabase.d.ts","sourceRoot":"","sources":["../../../src/api/checkTestDatabase.ts"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAIrD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mCAAmC,CACvD,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,OAAO,iBAmCtB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var checkTestDatabase_exports = {};
|
|
20
|
+
__export(checkTestDatabase_exports, {
|
|
21
|
+
checkTestDatabaseUrlMatchesProvider: () => checkTestDatabaseUrlMatchesProvider,
|
|
22
|
+
redactDatabaseUrl: () => redactDatabaseUrl
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(checkTestDatabase_exports);
|
|
25
|
+
var import_project_config = require("@cedarjs/project-config");
|
|
26
|
+
const PROVIDER_URL_SCHEMES = {
|
|
27
|
+
sqlite: ["file:"],
|
|
28
|
+
postgresql: ["postgres:", "postgresql:"],
|
|
29
|
+
postgres: ["postgres:", "postgresql:"],
|
|
30
|
+
cockroachdb: ["postgres:", "postgresql:"],
|
|
31
|
+
mysql: ["mysql:"],
|
|
32
|
+
sqlserver: ["sqlserver:"],
|
|
33
|
+
mongodb: ["mongodb:", "mongodb+srv:"]
|
|
34
|
+
};
|
|
35
|
+
function getUrlScheme(url) {
|
|
36
|
+
const match = url.match(/^([a-z][a-z0-9+.-]*:)/i);
|
|
37
|
+
return match?.[1]?.toLowerCase();
|
|
38
|
+
}
|
|
39
|
+
function redactDatabaseUrl(url) {
|
|
40
|
+
return url.replace(/:\/\/([^:/?#]+):([^@/?#]+)@/, "://$1:***@").replace(/((?:^|;)\s*password\s*=)[^;]*/gi, "$1***");
|
|
41
|
+
}
|
|
42
|
+
async function checkTestDatabaseUrlMatchesProvider(databaseUrl, usedFallback) {
|
|
43
|
+
let provider;
|
|
44
|
+
try {
|
|
45
|
+
provider = await (0, import_project_config.getPrismaDatasourceProvider)();
|
|
46
|
+
} catch {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const expectedSchemes = PROVIDER_URL_SCHEMES[provider];
|
|
50
|
+
if (!expectedSchemes) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const actualScheme = getUrlScheme(databaseUrl);
|
|
54
|
+
if (actualScheme && expectedSchemes.includes(actualScheme)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const redactedUrl = redactDatabaseUrl(databaseUrl);
|
|
58
|
+
const reason = usedFallback ? `TEST_DATABASE_URL is not set, so the default sqlite test database was used (${redactedUrl}), but your schema.prisma is configured for "${provider}". Set TEST_DATABASE_URL to a "${provider}" connection string to run tests.` : `TEST_DATABASE_URL (${redactedUrl}) does not match the "${provider}" provider configured in schema.prisma. Update TEST_DATABASE_URL to a "${provider}" connection string.`;
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Test database URL does not match your Prisma schema's provider.
|
|
61
|
+
|
|
62
|
+
${reason}`
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
66
|
+
0 && (module.exports = {
|
|
67
|
+
checkTestDatabaseUrlMatchesProvider,
|
|
68
|
+
redactDatabaseUrl
|
|
69
|
+
});
|
|
@@ -36,6 +36,7 @@ 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
38
|
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
39
|
+
var import_checkTestDatabase = require("../checkTestDatabase.js");
|
|
39
40
|
const CedarApiVitestEnvironment = {
|
|
40
41
|
name: "cedar-api",
|
|
41
42
|
viteEnvironment: "ssr",
|
|
@@ -48,7 +49,15 @@ const CedarApiVitestEnvironment = {
|
|
|
48
49
|
}
|
|
49
50
|
const cedarPaths = (0, import_project_config.getPaths)();
|
|
50
51
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
52
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
51
53
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
54
|
+
await (0, import_checkTestDatabase.checkTestDatabaseUrlMatchesProvider)(
|
|
55
|
+
process.env.DATABASE_URL,
|
|
56
|
+
usedFallback
|
|
57
|
+
);
|
|
58
|
+
console.log(
|
|
59
|
+
`Setting up test database: ${(0, import_checkTestDatabase.redactDatabaseUrl)(process.env.DATABASE_URL)}`
|
|
60
|
+
);
|
|
52
61
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
53
62
|
const pm = (0, import_packageManager.getPackageManager)();
|
|
54
63
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -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"}
|
|
@@ -36,13 +36,22 @@ 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
38
|
var import_packageManager = require("@cedarjs/project-config/packageManager");
|
|
39
|
+
var import_checkTestDatabase = require("../../../api/checkTestDatabase.js");
|
|
39
40
|
async function globalSetup_default() {
|
|
40
41
|
if (process.env.SKIP_DB_PUSH === "1") {
|
|
41
42
|
return;
|
|
42
43
|
}
|
|
43
44
|
const cedarPaths = (0, import_project_config.getPaths)();
|
|
44
45
|
const defaultDb = `file:${import_node_path.default.join(cedarPaths.generated.base, "test.db")}`;
|
|
46
|
+
const usedFallback = !process.env.TEST_DATABASE_URL;
|
|
45
47
|
process.env.DATABASE_URL = process.env.TEST_DATABASE_URL || defaultDb;
|
|
48
|
+
await (0, import_checkTestDatabase.checkTestDatabaseUrlMatchesProvider)(
|
|
49
|
+
process.env.DATABASE_URL,
|
|
50
|
+
usedFallback
|
|
51
|
+
);
|
|
52
|
+
console.log(
|
|
53
|
+
`Setting up test database: ${(0, import_checkTestDatabase.redactDatabaseUrl)(process.env.DATABASE_URL)}`
|
|
54
|
+
);
|
|
46
55
|
const command = process.env.TEST_DATABASE_STRATEGY === "reset" ? ["prisma", "migrate", "reset", "--force"] : ["prisma", "db", "push", "--force-reset", "--accept-data-loss"];
|
|
47
56
|
const pm = (0, import_packageManager.getPackageManager)();
|
|
48
57
|
const pmExec = pm === "pnpm" ? pm : "npx";
|
|
@@ -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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/testing",
|
|
3
|
-
"version": "5.0.7-next.
|
|
3
|
+
"version": "5.0.7-next.239",
|
|
4
4
|
"description": "Tools, wrappers and configuration for testing a Cedar project.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,6 +25,9 @@
|
|
|
25
25
|
"./dist/cjs/api/scenario.js": {
|
|
26
26
|
"default": "./dist/cjs/api/scenario.js"
|
|
27
27
|
},
|
|
28
|
+
"./dist/cjs/api/checkTestDatabase.js": {
|
|
29
|
+
"default": "./dist/cjs/api/checkTestDatabase.js"
|
|
30
|
+
},
|
|
28
31
|
"./dist/cjs/web/findCellMocks": {
|
|
29
32
|
"default": "./dist/cjs/web/findCellMocks.js"
|
|
30
33
|
},
|
|
@@ -117,10 +120,10 @@
|
|
|
117
120
|
},
|
|
118
121
|
"dependencies": {
|
|
119
122
|
"@babel/preset-env": "7.29.7",
|
|
120
|
-
"@cedarjs/babel-config": "5.0.7-next.
|
|
121
|
-
"@cedarjs/context": "5.0.7-next.
|
|
122
|
-
"@cedarjs/graphql-server": "5.0.7-next.
|
|
123
|
-
"@cedarjs/project-config": "5.0.7-next.
|
|
123
|
+
"@cedarjs/babel-config": "5.0.7-next.239",
|
|
124
|
+
"@cedarjs/context": "5.0.7-next.239",
|
|
125
|
+
"@cedarjs/graphql-server": "5.0.7-next.239",
|
|
126
|
+
"@cedarjs/project-config": "5.0.7-next.239",
|
|
124
127
|
"@testing-library/dom": "10.4.1",
|
|
125
128
|
"@testing-library/jest-dom": "6.9.1",
|
|
126
129
|
"@testing-library/react": "16.3.2",
|
|
@@ -142,20 +145,20 @@
|
|
|
142
145
|
},
|
|
143
146
|
"devDependencies": {
|
|
144
147
|
"@arethetypeswrong/cli": "0.18.5",
|
|
145
|
-
"@cedarjs/auth": "5.0.7-next.
|
|
146
|
-
"@cedarjs/framework-tools": "5.0.7-next.
|
|
147
|
-
"@cedarjs/router": "5.0.7-next.
|
|
148
|
-
"@cedarjs/web": "5.0.7-next.
|
|
148
|
+
"@cedarjs/auth": "5.0.7-next.239",
|
|
149
|
+
"@cedarjs/framework-tools": "5.0.7-next.239",
|
|
150
|
+
"@cedarjs/router": "5.0.7-next.239",
|
|
151
|
+
"@cedarjs/web": "5.0.7-next.239",
|
|
149
152
|
"concurrently": "9.2.4",
|
|
150
153
|
"jsdom": "27.4.0",
|
|
151
|
-
"publint": "0.3.
|
|
154
|
+
"publint": "0.3.23",
|
|
152
155
|
"typescript": "5.9.3",
|
|
153
156
|
"vitest": "4.1.10"
|
|
154
157
|
},
|
|
155
158
|
"peerDependencies": {
|
|
156
|
-
"@cedarjs/auth": "5.0.7-next.
|
|
157
|
-
"@cedarjs/router": "5.0.7-next.
|
|
158
|
-
"@cedarjs/web": "5.0.7-next.
|
|
159
|
+
"@cedarjs/auth": "5.0.7-next.239",
|
|
160
|
+
"@cedarjs/router": "5.0.7-next.239",
|
|
161
|
+
"@cedarjs/web": "5.0.7-next.239",
|
|
159
162
|
"vitest": "4.1.10"
|
|
160
163
|
},
|
|
161
164
|
"peerDependenciesMeta": {
|