@tachybase/test 1.6.14 → 1.6.15

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 CHANGED
@@ -8,7 +8,7 @@ import { Application, Gateway, AppSupervisor, PluginManager } from "@tego/core";
8
8
  import jwt from "jsonwebtoken";
9
9
  import qs from "qs";
10
10
  import fs from "node:fs";
11
- import { createRequire } from "node:module";
11
+ import { createRequire, Module } from "node:module";
12
12
  import os from "node:os";
13
13
  import path from "node:path";
14
14
  import { pathToFileURL } from "node:url";
@@ -221,6 +221,81 @@ const workspacePluginNameAliases = {
221
221
  };
222
222
  const ImportedTachybaseGlobal = TachybaseGlobalModule.getInstance ? TachybaseGlobalModule : TachybaseGlobalModule.default;
223
223
  const testUnsafeBuiltinPlugins = /* @__PURE__ */ new Set(["event-source", "worker-thread"]);
224
+ const cjsResolverPatched = Symbol.for("tego.test.server-env-cjs-resolver-patched");
225
+ function patchSlowBuffer() {
226
+ try {
227
+ const buffer = runtimeRequire("node:buffer");
228
+ buffer.SlowBuffer ??= buffer.Buffer;
229
+ } catch {
230
+ }
231
+ }
232
+ function patchCjsResolverForTestRuntime(workspaceRoot) {
233
+ if (globalThis[cjsResolverPatched]) {
234
+ return;
235
+ }
236
+ const resolvedWorkspaceRoot = workspaceRoot || process.cwd();
237
+ createRequire(path.resolve(resolvedWorkspaceRoot, "package.json"));
238
+ let testServerPath;
239
+ let testCorePath;
240
+ try {
241
+ testServerPath = selfRequire.resolve("@tego/server");
242
+ } catch {
243
+ }
244
+ try {
245
+ testCorePath = selfRequire.resolve("@tego/core");
246
+ } catch {
247
+ }
248
+ if (!testServerPath && !testCorePath) {
249
+ return;
250
+ }
251
+ const runtimeResolutions = /* @__PURE__ */ new Map();
252
+ if (testServerPath) {
253
+ runtimeResolutions.set("@tego/server", testServerPath);
254
+ try {
255
+ runtimeResolutions.set("@tego/server/package.json", selfRequire.resolve("@tego/server/package.json"));
256
+ } catch {
257
+ }
258
+ }
259
+ if (testCorePath) {
260
+ runtimeResolutions.set("@tego/core", testCorePath);
261
+ try {
262
+ runtimeResolutions.set("@tego/core/package.json", selfRequire.resolve("@tego/core/package.json"));
263
+ } catch {
264
+ }
265
+ }
266
+ const ModuleWithResolver = Module;
267
+ const originalResolveFilename = ModuleWithResolver._resolveFilename;
268
+ ModuleWithResolver._resolveFilename = function resolveTestRuntime(request, ...args) {
269
+ return runtimeResolutions.get(request) || originalResolveFilename.call(this, request, ...args);
270
+ };
271
+ globalThis[cjsResolverPatched] = true;
272
+ }
273
+ function configureWorkerGlobalsForContexts(workspaceRoot, pluginPaths) {
274
+ const workspaceRequire = createRequire(path.resolve(workspaceRoot, "package.json"));
275
+ const contexts = [runtimeRequire, selfRequire, workspaceRequire];
276
+ for (const packageName of ["@tego/core", "@tego/server"]) {
277
+ for (const req of [selfRequire, workspaceRequire]) {
278
+ try {
279
+ contexts.push(createRequire(req.resolve(`${packageName}/package.json`)));
280
+ } catch {
281
+ }
282
+ }
283
+ }
284
+ const workerPaths = [workspaceRoot, ...pluginPaths];
285
+ const uniqueContexts = [...new Set(contexts)];
286
+ for (const req of uniqueContexts) {
287
+ try {
288
+ const tachybaseGlobal = getTachybaseGlobal(req);
289
+ tachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
290
+ tachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
291
+ tachybaseGlobal.getInstance().set("WORKER_MODULES", []);
292
+ } catch (error) {
293
+ if (error.code !== "MODULE_NOT_FOUND") {
294
+ throw error;
295
+ }
296
+ }
297
+ }
298
+ }
224
299
  function createRuntimeRequire(workspaceRoot) {
225
300
  const hostPackageJson = path.resolve(workspaceRoot, "package.json");
226
301
  if (fs.existsSync(hostPackageJson)) {
@@ -621,6 +696,10 @@ function setupServerTestEnvironment(options = {}) {
621
696
  TachybaseGlobal.getInstance().set("WORKER_MODULES", []);
622
697
  process.env.TEGO_RUNTIME_HOME = path.join(os.tmpdir(), "test-sqlite");
623
698
  process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
699
+ patchSlowBuffer();
700
+ if (pluginPaths.length > 0) {
701
+ configureWorkerGlobalsForContexts(workspaceRoot, pluginPaths);
702
+ }
624
703
  const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
625
704
  for (const core of coreModules) {
626
705
  patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
@@ -713,6 +792,7 @@ export {
713
792
  isPg,
714
793
  mockDatabase2 as mockDatabase,
715
794
  mockServer,
795
+ patchCjsResolverForTestRuntime,
716
796
  pgOnly,
717
797
  randomStr,
718
798
  setupServerTestEnvironment,
@@ -5,4 +5,10 @@ export interface ServerTestEnvironmentOptions {
5
5
  disableRuntimePlugins?: boolean;
6
6
  disableOtherPlugins?: boolean;
7
7
  }
8
+ /**
9
+ * Patch CJS _resolveFilename so that @tego/server and @tego/core always resolve
10
+ * to the copy used by @tachybase/test. Call this at module level in your setup
11
+ * file (before setupServerTestEnvironment) to prevent dual-instance bugs.
12
+ */
13
+ export declare function patchCjsResolverForTestRuntime(workspaceRoot?: string): void;
8
14
  export declare function setupServerTestEnvironment(options?: ServerTestEnvironmentOptions): void;
package/es/vitest.d.ts CHANGED
@@ -1,11 +1,20 @@
1
1
  export interface TegoVitestConfigOptions {
2
2
  server?: {
3
3
  setupFile?: string;
4
+ /** Force CJS entry for @tachybase/test in server tests (avoids ESM createRequire issues). */
5
+ forceCjsEntry?: boolean;
4
6
  };
5
7
  client?: {
6
8
  setupFile?: string;
9
+ /** Override the default client test timeout (ms). */
10
+ testTimeout?: number;
7
11
  };
12
+ /** Additional path aliases merged with defaults from tsconfig.paths.json. */
13
+ aliases?: Array<{
14
+ find: string | RegExp;
15
+ replacement: string;
16
+ }>;
8
17
  }
9
- export declare function defineTegoVitestConfig(options?: TegoVitestConfigOptions): import("vite").UserConfig & Promise<import("vite").UserConfig> & (import("vitest/config.js").UserConfigFnObject & import("vitest/config.js").UserConfigExport);
10
- declare const _default: import("vite").UserConfig & Promise<import("vite").UserConfig> & (import("vitest/config.js").UserConfigFnObject & import("vitest/config.js").UserConfigExport);
18
+ export declare function defineTegoVitestConfig(options?: TegoVitestConfigOptions): import("vite").UserConfig;
19
+ declare const _default: import("vite").UserConfig;
11
20
  export default _default;
package/es/vitest.mjs CHANGED
@@ -53,9 +53,41 @@ function tsConfigPathsToAlias() {
53
53
  ];
54
54
  }
55
55
  function defineTegoVitestConfig(options = {}) {
56
- var _a, _b;
56
+ var _a, _b, _c, _d;
57
57
  const serverSetupFile = ((_a = options.server) == null ? void 0 : _a.setupFile) || resolve(packageRoot, "./setup/server.ts");
58
58
  const clientSetupFiles = [resolve(packageRoot, "./setup/client.ts"), (_b = options.client) == null ? void 0 : _b.setupFile].filter(Boolean);
59
+ const mergedAliases = [...options.aliases || [], ...tsConfigPathsToAlias()];
60
+ const serverProject = {
61
+ root: process.cwd(),
62
+ resolve: {
63
+ mainFields: ["module"]
64
+ },
65
+ extends: true,
66
+ test: {
67
+ name: "server",
68
+ setupFiles: serverSetupFile,
69
+ include: ["packages/**/__tests__/**/*.test.ts", "apps/**/__tests__/**/*.test.ts"],
70
+ exclude: [
71
+ "**/node_modules/**",
72
+ "**/dist/**",
73
+ "**/lib/**",
74
+ "**/es/**",
75
+ "**/e2e/**",
76
+ "**/__e2e__/**",
77
+ "**/{vitest,commitlint}.config.*",
78
+ "packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"
79
+ ],
80
+ alias: [...mergedAliases]
81
+ }
82
+ };
83
+ if ((_c = options.server) == null ? void 0 : _c.forceCjsEntry) {
84
+ try {
85
+ const testRequire = createRequire(path.resolve(process.cwd(), "node_modules/@tachybase/test/package.json"));
86
+ const testCjsEntry = testRequire.resolve("@tachybase/test");
87
+ serverProject.test.alias.push({ find: "@tachybase/test", replacement: testCjsEntry });
88
+ } catch {
89
+ }
90
+ }
59
91
  return defineConfig({
60
92
  test: {
61
93
  testTimeout: 6e4,
@@ -73,30 +105,9 @@ function defineTegoVitestConfig(options = {}) {
73
105
  },
74
106
  silent: !!process.env.GITHUB_ACTIONS,
75
107
  globals: true,
76
- alias: tsConfigPathsToAlias(),
108
+ alias: mergedAliases,
77
109
  projects: [
78
- {
79
- root: process.cwd(),
80
- resolve: {
81
- mainFields: ["module"]
82
- },
83
- extends: true,
84
- test: {
85
- name: "server",
86
- setupFiles: serverSetupFile,
87
- include: ["packages/**/__tests__/**/*.test.ts", "apps/**/__tests__/**/*.test.ts"],
88
- exclude: [
89
- "**/node_modules/**",
90
- "**/dist/**",
91
- "**/lib/**",
92
- "**/es/**",
93
- "**/e2e/**",
94
- "**/__e2e__/**",
95
- "**/{vitest,commitlint}.config.*",
96
- "packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"
97
- ]
98
- }
99
- },
110
+ serverProject,
100
111
  {
101
112
  // @ts-ignore
102
113
  plugins: [react()],
@@ -113,7 +124,8 @@ function defineTegoVitestConfig(options = {}) {
113
124
  setupFiles: clientSetupFiles,
114
125
  environment: "jsdom",
115
126
  css: false,
116
- alias: tsConfigPathsToAlias(),
127
+ alias: mergedAliases,
128
+ testTimeout: (_d = options.client) == null ? void 0 : _d.testTimeout,
117
129
  include: ["packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"],
118
130
  exclude: [
119
131
  "**/node_modules/**",
@@ -5,4 +5,10 @@ export interface ServerTestEnvironmentOptions {
5
5
  disableRuntimePlugins?: boolean;
6
6
  disableOtherPlugins?: boolean;
7
7
  }
8
+ /**
9
+ * Patch CJS _resolveFilename so that @tego/server and @tego/core always resolve
10
+ * to the copy used by @tachybase/test. Call this at module level in your setup
11
+ * file (before setupServerTestEnvironment) to prevent dual-instance bugs.
12
+ */
13
+ export declare function patchCjsResolverForTestRuntime(workspaceRoot?: string): void;
8
14
  export declare function setupServerTestEnvironment(options?: ServerTestEnvironmentOptions): void;
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var setupTestEnvironment_exports = {};
30
30
  __export(setupTestEnvironment_exports, {
31
+ patchCjsResolverForTestRuntime: () => patchCjsResolverForTestRuntime,
31
32
  setupServerTestEnvironment: () => setupServerTestEnvironment
32
33
  });
33
34
  module.exports = __toCommonJS(setupTestEnvironment_exports);
@@ -46,6 +47,84 @@ const workspacePluginNameAliases = {
46
47
  };
47
48
  const ImportedTachybaseGlobal = import_globals.default.getInstance ? import_globals.default : import_globals.default.default;
48
49
  const testUnsafeBuiltinPlugins = /* @__PURE__ */ new Set(["event-source", "worker-thread"]);
50
+ const cjsResolverPatched = Symbol.for("tego.test.server-env-cjs-resolver-patched");
51
+ function patchSlowBuffer() {
52
+ try {
53
+ const buffer = runtimeRequire("node:buffer");
54
+ buffer.SlowBuffer ??= buffer.Buffer;
55
+ } catch {
56
+ }
57
+ }
58
+ __name(patchSlowBuffer, "patchSlowBuffer");
59
+ function patchCjsResolverForTestRuntime(workspaceRoot) {
60
+ if (globalThis[cjsResolverPatched]) {
61
+ return;
62
+ }
63
+ const resolvedWorkspaceRoot = workspaceRoot || process.cwd();
64
+ const workspaceRequire = (0, import_node_module.createRequire)(import_node_path.default.resolve(resolvedWorkspaceRoot, "package.json"));
65
+ let testServerPath;
66
+ let testCorePath;
67
+ try {
68
+ testServerPath = selfRequire.resolve("@tego/server");
69
+ } catch {
70
+ }
71
+ try {
72
+ testCorePath = selfRequire.resolve("@tego/core");
73
+ } catch {
74
+ }
75
+ if (!testServerPath && !testCorePath) {
76
+ return;
77
+ }
78
+ const runtimeResolutions = /* @__PURE__ */ new Map();
79
+ if (testServerPath) {
80
+ runtimeResolutions.set("@tego/server", testServerPath);
81
+ try {
82
+ runtimeResolutions.set("@tego/server/package.json", selfRequire.resolve("@tego/server/package.json"));
83
+ } catch {
84
+ }
85
+ }
86
+ if (testCorePath) {
87
+ runtimeResolutions.set("@tego/core", testCorePath);
88
+ try {
89
+ runtimeResolutions.set("@tego/core/package.json", selfRequire.resolve("@tego/core/package.json"));
90
+ } catch {
91
+ }
92
+ }
93
+ const ModuleWithResolver = import_node_module.Module;
94
+ const originalResolveFilename = ModuleWithResolver._resolveFilename;
95
+ ModuleWithResolver._resolveFilename = /* @__PURE__ */ __name(function resolveTestRuntime(request, ...args) {
96
+ return runtimeResolutions.get(request) || originalResolveFilename.call(this, request, ...args);
97
+ }, "resolveTestRuntime");
98
+ globalThis[cjsResolverPatched] = true;
99
+ }
100
+ __name(patchCjsResolverForTestRuntime, "patchCjsResolverForTestRuntime");
101
+ function configureWorkerGlobalsForContexts(workspaceRoot, pluginPaths) {
102
+ const workspaceRequire = (0, import_node_module.createRequire)(import_node_path.default.resolve(workspaceRoot, "package.json"));
103
+ const contexts = [runtimeRequire, selfRequire, workspaceRequire];
104
+ for (const packageName of ["@tego/core", "@tego/server"]) {
105
+ for (const req of [selfRequire, workspaceRequire]) {
106
+ try {
107
+ contexts.push((0, import_node_module.createRequire)(req.resolve(`${packageName}/package.json`)));
108
+ } catch {
109
+ }
110
+ }
111
+ }
112
+ const workerPaths = [workspaceRoot, ...pluginPaths];
113
+ const uniqueContexts = [...new Set(contexts)];
114
+ for (const req of uniqueContexts) {
115
+ try {
116
+ const tachybaseGlobal = getTachybaseGlobal(req);
117
+ tachybaseGlobal.getInstance().set("PLUGIN_PATHS", pluginPaths);
118
+ tachybaseGlobal.getInstance().set("WORKER_PATHS", workerPaths);
119
+ tachybaseGlobal.getInstance().set("WORKER_MODULES", []);
120
+ } catch (error) {
121
+ if (error.code !== "MODULE_NOT_FOUND") {
122
+ throw error;
123
+ }
124
+ }
125
+ }
126
+ }
127
+ __name(configureWorkerGlobalsForContexts, "configureWorkerGlobalsForContexts");
49
128
  function createRuntimeRequire(workspaceRoot) {
50
129
  const hostPackageJson = import_node_path.default.resolve(workspaceRoot, "package.json");
51
130
  if (import_node_fs.default.existsSync(hostPackageJson)) {
@@ -459,6 +538,10 @@ function setupServerTestEnvironment(options = {}) {
459
538
  TachybaseGlobal.getInstance().set("WORKER_MODULES", []);
460
539
  process.env.TEGO_RUNTIME_HOME = import_node_path.default.join(import_node_os.default.tmpdir(), "test-sqlite");
461
540
  process.env.APP_ENV_PATH = process.env.APP_ENV_PATH || ".env.test";
541
+ patchSlowBuffer();
542
+ if (pluginPaths.length > 0) {
543
+ configureWorkerGlobalsForContexts(workspaceRoot, pluginPaths);
544
+ }
462
545
  const coreModules = getCoreModules(workspaceRoot, runtimeRequire2);
463
546
  for (const core of coreModules) {
464
547
  patchPluginRuntime(core, workspaceRoot, packageDirByPluginName);
@@ -479,5 +562,6 @@ function setupServerTestEnvironment(options = {}) {
479
562
  __name(setupServerTestEnvironment, "setupServerTestEnvironment");
480
563
  // Annotate the CommonJS export names for ESM import in node:
481
564
  0 && (module.exports = {
565
+ patchCjsResolverForTestRuntime,
482
566
  setupServerTestEnvironment
483
567
  });
package/lib/vitest.d.ts CHANGED
@@ -1,11 +1,20 @@
1
1
  export interface TegoVitestConfigOptions {
2
2
  server?: {
3
3
  setupFile?: string;
4
+ /** Force CJS entry for @tachybase/test in server tests (avoids ESM createRequire issues). */
5
+ forceCjsEntry?: boolean;
4
6
  };
5
7
  client?: {
6
8
  setupFile?: string;
9
+ /** Override the default client test timeout (ms). */
10
+ testTimeout?: number;
7
11
  };
12
+ /** Additional path aliases merged with defaults from tsconfig.paths.json. */
13
+ aliases?: Array<{
14
+ find: string | RegExp;
15
+ replacement: string;
16
+ }>;
8
17
  }
9
- export declare function defineTegoVitestConfig(options?: TegoVitestConfigOptions): import("vite").UserConfig & Promise<import("vite").UserConfig> & (import("vitest/config.js").UserConfigFnObject & import("vitest/config.js").UserConfigExport);
10
- declare const _default: import("vite").UserConfig & Promise<import("vite").UserConfig> & (import("vitest/config.js").UserConfigFnObject & import("vitest/config.js").UserConfigExport);
18
+ export declare function defineTegoVitestConfig(options?: TegoVitestConfigOptions): import("vite").UserConfig;
19
+ declare const _default: import("vite").UserConfig;
11
20
  export default _default;
package/lib/vitest.js CHANGED
@@ -88,9 +88,41 @@ function tsConfigPathsToAlias() {
88
88
  }
89
89
  __name(tsConfigPathsToAlias, "tsConfigPathsToAlias");
90
90
  function defineTegoVitestConfig(options = {}) {
91
- var _a, _b;
91
+ var _a, _b, _c, _d;
92
92
  const serverSetupFile = ((_a = options.server) == null ? void 0 : _a.setupFile) || (0, import_node_path.resolve)(packageRoot, "./setup/server.ts");
93
93
  const clientSetupFiles = [(0, import_node_path.resolve)(packageRoot, "./setup/client.ts"), (_b = options.client) == null ? void 0 : _b.setupFile].filter(Boolean);
94
+ const mergedAliases = [...options.aliases || [], ...tsConfigPathsToAlias()];
95
+ const serverProject = {
96
+ root: process.cwd(),
97
+ resolve: {
98
+ mainFields: ["module"]
99
+ },
100
+ extends: true,
101
+ test: {
102
+ name: "server",
103
+ setupFiles: serverSetupFile,
104
+ include: ["packages/**/__tests__/**/*.test.ts", "apps/**/__tests__/**/*.test.ts"],
105
+ exclude: [
106
+ "**/node_modules/**",
107
+ "**/dist/**",
108
+ "**/lib/**",
109
+ "**/es/**",
110
+ "**/e2e/**",
111
+ "**/__e2e__/**",
112
+ "**/{vitest,commitlint}.config.*",
113
+ "packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"
114
+ ],
115
+ alias: [...mergedAliases]
116
+ }
117
+ };
118
+ if ((_c = options.server) == null ? void 0 : _c.forceCjsEntry) {
119
+ try {
120
+ const testRequire = (0, import_node_module.createRequire)(import_node_path.default.resolve(process.cwd(), "node_modules/@tachybase/test/package.json"));
121
+ const testCjsEntry = testRequire.resolve("@tachybase/test");
122
+ serverProject.test.alias.push({ find: "@tachybase/test", replacement: testCjsEntry });
123
+ } catch {
124
+ }
125
+ }
94
126
  return (0, import_config.defineConfig)({
95
127
  test: {
96
128
  testTimeout: 6e4,
@@ -108,30 +140,9 @@ function defineTegoVitestConfig(options = {}) {
108
140
  },
109
141
  silent: !!process.env.GITHUB_ACTIONS,
110
142
  globals: true,
111
- alias: tsConfigPathsToAlias(),
143
+ alias: mergedAliases,
112
144
  projects: [
113
- {
114
- root: process.cwd(),
115
- resolve: {
116
- mainFields: ["module"]
117
- },
118
- extends: true,
119
- test: {
120
- name: "server",
121
- setupFiles: serverSetupFile,
122
- include: ["packages/**/__tests__/**/*.test.ts", "apps/**/__tests__/**/*.test.ts"],
123
- exclude: [
124
- "**/node_modules/**",
125
- "**/dist/**",
126
- "**/lib/**",
127
- "**/es/**",
128
- "**/e2e/**",
129
- "**/__e2e__/**",
130
- "**/{vitest,commitlint}.config.*",
131
- "packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"
132
- ]
133
- }
134
- },
145
+ serverProject,
135
146
  {
136
147
  // @ts-ignore
137
148
  plugins: [(0, import_plugin_react.default)()],
@@ -148,7 +159,8 @@ function defineTegoVitestConfig(options = {}) {
148
159
  setupFiles: clientSetupFiles,
149
160
  environment: "jsdom",
150
161
  css: false,
151
- alias: tsConfigPathsToAlias(),
162
+ alias: mergedAliases,
163
+ testTimeout: (_d = options.client) == null ? void 0 : _d.testTimeout,
152
164
  include: ["packages/**/{sdk,client,schema,components}/**/__tests__/**/*.{test,spec}.{ts,tsx}"],
153
165
  exclude: [
154
166
  "**/node_modules/**",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tachybase/test",
3
- "version": "1.6.14",
3
+ "version": "1.6.15",
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/database": "1.6.14",
117
- "@tachybase/globals": "1.6.14",
118
- "@tachybase/schema": "1.6.14",
119
- "@tego/core": "1.6.14"
116
+ "@tachybase/database": "1.6.15",
117
+ "@tachybase/schema": "1.6.15",
118
+ "@tego/core": "1.6.15",
119
+ "@tachybase/globals": "1.6.15"
120
120
  }
121
121
  }
package/setup/server.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import path from 'node:path';
2
- import { setupServerTestEnvironment } from '@tachybase/test/server';
2
+ import { patchCjsResolverForTestRuntime, setupServerTestEnvironment } from '@tachybase/test/server';
3
3
  import { initEnv } from '@tego/devkit';
4
4
 
5
+ // Patch CJS resolver BEFORE any test modules load to prevent dual-instance bugs
6
+ patchCjsResolverForTestRuntime();
7
+
5
8
  setupServerTestEnvironment({
6
9
  workspaceRoot: process.cwd(),
7
10
  pluginPaths: [path.resolve(process.cwd(), 'packages')],