@tachybase/test 1.6.13-alpha.2 → 1.6.13-alpha.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/es/index.mjs +31 -22
- package/lib/server/index.js +13 -3
- package/lib/server/setupTestEnvironment.js +19 -19
- package/package.json +5 -5
- package/setup/client.ts +1 -1
package/es/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import TachybaseGlobalModule from "@tachybase/globals";
|
|
2
|
-
import { describe } from "vitest";
|
|
3
2
|
import ws from "ws";
|
|
4
3
|
import { mockDatabase } from "@tachybase/database";
|
|
5
4
|
import { mockDatabase as mockDatabase2 } from "@tachybase/database";
|
|
@@ -210,6 +209,7 @@ async function createMockServer(options = {}) {
|
|
|
210
209
|
return app;
|
|
211
210
|
}
|
|
212
211
|
const runtimeRequire = createRequire(path.resolve(process.cwd(), "package.json"));
|
|
212
|
+
const selfRequire = createRequire(require.resolve("@tachybase/test/package.json"));
|
|
213
213
|
const workspacePluginNameAliases = {
|
|
214
214
|
map: "block-map"
|
|
215
215
|
};
|
|
@@ -233,26 +233,18 @@ function getTachybaseGlobal(runtimeRequire2) {
|
|
|
233
233
|
throw error;
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
|
-
function getCoreModules(
|
|
236
|
+
function getCoreModules() {
|
|
237
237
|
const cores = [];
|
|
238
238
|
try {
|
|
239
|
-
cores.push(
|
|
240
|
-
} catch (
|
|
241
|
-
if (
|
|
242
|
-
throw error;
|
|
243
|
-
}
|
|
239
|
+
cores.push(selfRequire("@tego/core"));
|
|
240
|
+
} catch (e) {
|
|
241
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
244
242
|
}
|
|
245
243
|
try {
|
|
246
|
-
cores.push(
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
for (const mod of Object.values(runtimeRequire2.cache)) {
|
|
252
|
-
const exports = mod == null ? void 0 : mod.exports;
|
|
253
|
-
if ((exports == null ? void 0 : exports.Plugin) && (exports == null ? void 0 : exports.PluginManager)) {
|
|
254
|
-
cores.push(exports);
|
|
255
|
-
}
|
|
244
|
+
cores.push(selfRequire("@tego/server"));
|
|
245
|
+
cores.push(createRequire(selfRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
246
|
+
} catch (e) {
|
|
247
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
256
248
|
}
|
|
257
249
|
return [...new Set(cores)];
|
|
258
250
|
}
|
|
@@ -292,12 +284,19 @@ function workspacePackageDirByPackageName(workspaceRoot, packageName, map = {})
|
|
|
292
284
|
return fs.existsSync(packageJsonPath) ? packageDir : null;
|
|
293
285
|
}
|
|
294
286
|
function workspaceServerEntry(workspaceRoot, packageDir) {
|
|
287
|
+
const libEntry = path.resolve(workspaceRoot, "packages", packageDir, "lib/server/index.js");
|
|
288
|
+
if (fs.existsSync(libEntry)) {
|
|
289
|
+
return libEntry;
|
|
290
|
+
}
|
|
291
|
+
const distEntry = path.resolve(workspaceRoot, "packages", packageDir, "dist/server/index.js");
|
|
292
|
+
if (fs.existsSync(distEntry)) {
|
|
293
|
+
return distEntry;
|
|
294
|
+
}
|
|
295
295
|
const sourceEntry = path.resolve(workspaceRoot, "packages", packageDir, "src/server/index.ts");
|
|
296
296
|
if (fs.existsSync(sourceEntry)) {
|
|
297
297
|
return sourceEntry;
|
|
298
298
|
}
|
|
299
|
-
|
|
300
|
-
return fs.existsSync(compiledEntry) ? compiledEntry : null;
|
|
299
|
+
return null;
|
|
301
300
|
}
|
|
302
301
|
function getModuleDefault(mod) {
|
|
303
302
|
var _a;
|
|
@@ -578,7 +577,7 @@ function setupServerTestEnvironment(options = {}) {
|
|
|
578
577
|
TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
|
|
579
578
|
process.env.TEGO_RUNTIME_HOME = path.join(os.tmpdir(), "test-sqlite");
|
|
580
579
|
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
|
|
581
|
-
const coreModules = getCoreModules(
|
|
580
|
+
const coreModules = getCoreModules();
|
|
582
581
|
for (const core of coreModules) {
|
|
583
582
|
patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
|
|
584
583
|
patchPluginManager(core, {
|
|
@@ -597,13 +596,23 @@ function setupServerTestEnvironment(options = {}) {
|
|
|
597
596
|
}
|
|
598
597
|
const noopDescribe = () => {
|
|
599
598
|
};
|
|
599
|
+
function getDescribe() {
|
|
600
|
+
const desc = globalThis.describe;
|
|
601
|
+
if (!desc) {
|
|
602
|
+
throw new Error(
|
|
603
|
+
"globalThis.describe is not available. Ensure your test runner (vitest/jest) provides it globally or configure globals: true."
|
|
604
|
+
);
|
|
605
|
+
}
|
|
606
|
+
return desc;
|
|
607
|
+
}
|
|
600
608
|
const pgOnly = () => {
|
|
601
609
|
var _a, _b;
|
|
602
610
|
const isPostgres = ((_b = (_a = TachybaseGlobalModule.settings) == null ? void 0 : _a.database) == null ? void 0 : _b.dialect) === "postgres";
|
|
611
|
+
const desc = getDescribe();
|
|
603
612
|
if (isPostgres) {
|
|
604
|
-
return
|
|
613
|
+
return desc;
|
|
605
614
|
}
|
|
606
|
-
return
|
|
615
|
+
return desc.skip || noopDescribe;
|
|
607
616
|
};
|
|
608
617
|
const isPg = () => {
|
|
609
618
|
var _a, _b;
|
package/lib/server/index.js
CHANGED
|
@@ -40,7 +40,6 @@ __export(server_exports, {
|
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(server_exports);
|
|
42
42
|
var import_globals = __toESM(require("@tachybase/globals"));
|
|
43
|
-
var import_vitest = require("vitest");
|
|
44
43
|
var import_ws = __toESM(require("ws"));
|
|
45
44
|
var import_database = require("@tachybase/database");
|
|
46
45
|
var import_supertest = __toESM(require("supertest"));
|
|
@@ -48,13 +47,24 @@ __reExport(server_exports, require("./mockServer"), module.exports);
|
|
|
48
47
|
__reExport(server_exports, require("./setupTestEnvironment"), module.exports);
|
|
49
48
|
const noopDescribe = /* @__PURE__ */ __name(() => {
|
|
50
49
|
}, "noopDescribe");
|
|
50
|
+
function getDescribe() {
|
|
51
|
+
const desc = globalThis.describe;
|
|
52
|
+
if (!desc) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
"globalThis.describe is not available. Ensure your test runner (vitest/jest) provides it globally or configure globals: true."
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
return desc;
|
|
58
|
+
}
|
|
59
|
+
__name(getDescribe, "getDescribe");
|
|
51
60
|
const pgOnly = /* @__PURE__ */ __name(() => {
|
|
52
61
|
var _a, _b;
|
|
53
62
|
const isPostgres = ((_b = (_a = import_globals.default.settings) == null ? void 0 : _a.database) == null ? void 0 : _b.dialect) === "postgres";
|
|
63
|
+
const desc = getDescribe();
|
|
54
64
|
if (isPostgres) {
|
|
55
|
-
return
|
|
65
|
+
return desc;
|
|
56
66
|
}
|
|
57
|
-
return
|
|
67
|
+
return desc.skip || noopDescribe;
|
|
58
68
|
}, "pgOnly");
|
|
59
69
|
const isPg = /* @__PURE__ */ __name(() => {
|
|
60
70
|
var _a, _b;
|
|
@@ -38,6 +38,7 @@ var import_node_path = __toESM(require("node:path"));
|
|
|
38
38
|
var import_node_url = require("node:url");
|
|
39
39
|
var import_globals = __toESM(require("@tachybase/globals"));
|
|
40
40
|
const runtimeRequire = (0, import_node_module.createRequire)(import_node_path.default.resolve(process.cwd(), "package.json"));
|
|
41
|
+
const selfRequire = (0, import_node_module.createRequire)(require.resolve("@tachybase/test/package.json"));
|
|
41
42
|
const workspacePluginNameAliases = {
|
|
42
43
|
map: "block-map"
|
|
43
44
|
};
|
|
@@ -63,26 +64,18 @@ function getTachybaseGlobal(runtimeRequire2) {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
__name(getTachybaseGlobal, "getTachybaseGlobal");
|
|
66
|
-
function getCoreModules(
|
|
67
|
+
function getCoreModules() {
|
|
67
68
|
const cores = [];
|
|
68
69
|
try {
|
|
69
|
-
cores.push(
|
|
70
|
-
} catch (
|
|
71
|
-
if (
|
|
72
|
-
throw error;
|
|
73
|
-
}
|
|
70
|
+
cores.push(selfRequire("@tego/core"));
|
|
71
|
+
} catch (e) {
|
|
72
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
74
73
|
}
|
|
75
74
|
try {
|
|
76
|
-
cores.push(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
for (const mod of Object.values(runtimeRequire2.cache)) {
|
|
82
|
-
const exports2 = mod == null ? void 0 : mod.exports;
|
|
83
|
-
if ((exports2 == null ? void 0 : exports2.Plugin) && (exports2 == null ? void 0 : exports2.PluginManager)) {
|
|
84
|
-
cores.push(exports2);
|
|
85
|
-
}
|
|
75
|
+
cores.push(selfRequire("@tego/server"));
|
|
76
|
+
cores.push((0, import_node_module.createRequire)(selfRequire.resolve("@tego/server/package.json"))("@tego/core"));
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if ((e == null ? void 0 : e.code) !== "MODULE_NOT_FOUND") throw e;
|
|
86
79
|
}
|
|
87
80
|
return [...new Set(cores)];
|
|
88
81
|
}
|
|
@@ -126,12 +119,19 @@ function workspacePackageDirByPackageName(workspaceRoot, packageName, map = {})
|
|
|
126
119
|
}
|
|
127
120
|
__name(workspacePackageDirByPackageName, "workspacePackageDirByPackageName");
|
|
128
121
|
function workspaceServerEntry(workspaceRoot, packageDir) {
|
|
122
|
+
const libEntry = import_node_path.default.resolve(workspaceRoot, "packages", packageDir, "lib/server/index.js");
|
|
123
|
+
if (import_node_fs.default.existsSync(libEntry)) {
|
|
124
|
+
return libEntry;
|
|
125
|
+
}
|
|
126
|
+
const distEntry = import_node_path.default.resolve(workspaceRoot, "packages", packageDir, "dist/server/index.js");
|
|
127
|
+
if (import_node_fs.default.existsSync(distEntry)) {
|
|
128
|
+
return distEntry;
|
|
129
|
+
}
|
|
129
130
|
const sourceEntry = import_node_path.default.resolve(workspaceRoot, "packages", packageDir, "src/server/index.ts");
|
|
130
131
|
if (import_node_fs.default.existsSync(sourceEntry)) {
|
|
131
132
|
return sourceEntry;
|
|
132
133
|
}
|
|
133
|
-
|
|
134
|
-
return import_node_fs.default.existsSync(compiledEntry) ? compiledEntry : null;
|
|
134
|
+
return null;
|
|
135
135
|
}
|
|
136
136
|
__name(workspaceServerEntry, "workspaceServerEntry");
|
|
137
137
|
function getModuleDefault(mod) {
|
|
@@ -419,7 +419,7 @@ function setupServerTestEnvironment(options = {}) {
|
|
|
419
419
|
TachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
|
|
420
420
|
process.env.TEGO_RUNTIME_HOME = import_node_path.default.join(import_node_os.default.tmpdir(), "test-sqlite");
|
|
421
421
|
process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
|
|
422
|
-
const coreModules = getCoreModules(
|
|
422
|
+
const coreModules = getCoreModules();
|
|
423
423
|
for (const core of coreModules) {
|
|
424
424
|
patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
|
|
425
425
|
patchPluginManager(core, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tachybase/test",
|
|
3
|
-
"version": "1.6.13-alpha.
|
|
3
|
+
"version": "1.6.13-alpha.4",
|
|
4
4
|
"homepage": "https://github.com/tegojs/tego#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/tegojs/tego/issues"
|
|
@@ -113,9 +113,9 @@
|
|
|
113
113
|
"vite": "^7.1.10",
|
|
114
114
|
"vitest": "^3.2.4",
|
|
115
115
|
"ws": "^8.18.3",
|
|
116
|
-
"@tachybase/
|
|
117
|
-
"@tachybase/
|
|
118
|
-
"@tachybase/
|
|
119
|
-
"@tego/core": "1.6.13-alpha.
|
|
116
|
+
"@tachybase/database": "1.6.13-alpha.4",
|
|
117
|
+
"@tachybase/globals": "1.6.13-alpha.4",
|
|
118
|
+
"@tachybase/schema": "1.6.13-alpha.4",
|
|
119
|
+
"@tego/core": "1.6.13-alpha.4"
|
|
120
120
|
}
|
|
121
121
|
}
|
package/setup/client.ts
CHANGED