Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(sdk): the smokes read the engine's own build output

esengine602af8329207
diff --git a/sdk/tests/entity-hierarchy.test.ts b/sdk/tests/entity-hierarchy.test.ts
index 568f71e67..ff5791c6b 100644
--- a/sdk/tests/entity-hierarchy.test.ts
+++ b/sdk/tests/entity-hierarchy.test.ts
@@ -3,7 +3,7 @@
/**
* Integration tests: Entity parent-child hierarchy via real WASM module.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
* Run `node build-tools/cli.js build -t web` first if missing.
*/
import { describe, it, expect, beforeAll } from 'vitest';
diff --git a/sdk/tests/helpers/loadWasm.ts b/sdk/tests/helpers/loadWasm.ts
index 769ef50dd..d4562df20 100644
--- a/sdk/tests/helpers/loadWasm.ts
+++ b/sdk/tests/helpers/loadWasm.ts
@@ -9,7 +9,7 @@ import type { ESEngineModule } from '../../src/wasm';
* built WASM SDK (esengine.js + esengine.wasm). Resolution order:
* 1. $ESENGINE_WASM_DIR — explicit override (CI passes the build dir)
* 2. <repo>/build/wasm/web — the in-repo CMake/Emscripten output
- * 3. <repo>/desktop/public/wasm — legacy path when built inside the editor repo
+ * 3. <repo>/desktop/public/wasm — the copy synced into the editor, when checked out
*
* The first candidate that actually contains esengine.wasm wins. If none do,
* {@link HAS_WASM} is false and the integration suites skip themselves via
diff --git a/sdk/tests/helpers/wasmDir.mjs b/sdk/tests/helpers/wasmDir.mjs
new file mode 100644
index 000000000..7819ad94a
--- /dev/null
+++ b/sdk/tests/helpers/wasmDir.mjs
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file wasmDir.mjs — where the plain-node smoke scripts find the built WASM.
+ *
+ * The .mjs smokes cannot import the TypeScript {@link ../loadWasm.ts}, so this
+ * mirrors its resolution order. `build/wasm/web` is the authoritative build
+ * output; `desktop/public/wasm` is a synced copy that only exists when the
+ * editor submodule is checked out, so nothing engine-side may require it.
+ */
+import { existsSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const HERE = path.dirname(fileURLToPath(import.meta.url));
+const ROOT = path.resolve(HERE, '../../..');
+
+/** First candidate that actually holds `probe`; falls back to the build output. */
+export function resolveWasmDir(probe = 'esengine.wasm') {
+ const candidates = [
+ process.env.ESENGINE_WASM_DIR,
+ path.join(ROOT, 'build/wasm/web'),
+ path.join(ROOT, 'desktop/public/wasm'),
+ ].filter(Boolean);
+ for (const dir of candidates) {
+ if (existsSync(path.join(dir, probe))) return dir;
+ }
+ return path.join(ROOT, 'build/wasm/web');
+}
+
+/**
+ * Skips the caller (exit 0) when the engine has not been built. A smoke that
+ * cannot find the binary has verified nothing; exiting non-zero would make an
+ * unbuilt checkout indistinguishable from a real regression.
+ */
+export function requireWasm(probe) {
+ const dir = resolveWasmDir(probe);
+ if (!existsSync(path.join(dir, probe))) {
+ console.log(`SKIP ${probe} is not built (looked in ${dir}) — run \`node build-tools/cli.js build -t web\``);
+ process.exit(0);
+ }
+ return dir;
+}
diff --git a/sdk/tests/mesh-box-integration.test.ts b/sdk/tests/mesh-box-integration.test.ts
index cb7e4c362..482bf7330 100644
--- a/sdk/tests/mesh-box-integration.test.ts
+++ b/sdk/tests/mesh-box-integration.test.ts
@@ -7,7 +7,7 @@
* not in the component at all — so the engine is what answers. An editor that
* boxes a mesh by its component alone gets nothing to click.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
*/
import { describe, it, expect, beforeAll } from 'vitest';
import { App } from '../src/app/app';
diff --git a/sdk/tests/mover-smoke.mjs b/sdk/tests/mover-smoke.mjs
index a6f5af3ca..6e229c287 100644
--- a/sdk/tests/mover-smoke.mjs
+++ b/sdk/tests/mover-smoke.mjs
@@ -3,11 +3,10 @@
// resting/wedge/landing behavior plus the skin-width, floor-snap, and ceiling
// options wired through from the CharacterController component.
import { readFileSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
import path from 'node:path';
+import { requireWasm } from './helpers/wasmDir.mjs';
-const dir = path.dirname(fileURLToPath(import.meta.url));
-const wasmDir = path.resolve(dir, '../../desktop/public/wasm');
+const wasmDir = requireWasm('physics.wasm');
const factory = (await import('file://' + path.join(wasmDir, 'physics.js').replace(/\\/g, '/'))).default;
const wasmBinary = readFileSync(path.join(wasmDir, 'physics.wasm'));
const m = await factory({ wasmBinary });
diff --git a/sdk/tests/physics-features-smoke.mjs b/sdk/tests/physics-features-smoke.mjs
index 2b9792ef1..087f88da6 100644
--- a/sdk/tests/physics-features-smoke.mjs
+++ b/sdk/tests/physics-features-smoke.mjs
@@ -2,11 +2,10 @@
// Loads the built physics wasm directly and asserts each behaviour end-to-end, the
// same pattern as mover-smoke.mjs / sensor-smoke.mjs.
import { readFileSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
import path from 'node:path';
+import { requireWasm } from './helpers/wasmDir.mjs';
-const dir = path.dirname(fileURLToPath(import.meta.url));
-const wasmDir = path.resolve(dir, '../../desktop/public/wasm');
+const wasmDir = requireWasm('physics.wasm');
const factory = (await import('file://' + path.join(wasmDir, 'physics.js').replace(/\\/g, '/'))).default;
const wasmBinary = readFileSync(path.join(wasmDir, 'physics.wasm'));
const m = await factory({ wasmBinary });
diff --git a/sdk/tests/physics3d-smoke.mjs b/sdk/tests/physics3d-smoke.mjs
index 371a8e024..9f2f3ec7f 100644
--- a/sdk/tests/physics3d-smoke.mjs
+++ b/sdk/tests/physics3d-smoke.mjs
@@ -2,11 +2,10 @@
// each behaviour against a value arithmetic predicts. A world that steps without
// throwing proves nothing about where anything ended up.
import { readFileSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
import path from 'node:path';
+import { requireWasm } from './helpers/wasmDir.mjs';
-const dir = path.dirname(fileURLToPath(import.meta.url));
-const wasmDir = path.resolve(dir, '../../desktop/public/wasm');
+const wasmDir = requireWasm('physics3d.wasm');
const factory = (await import('file://' + path.join(wasmDir, 'physics3d.js').replace(/\\/g, '/'))).default;
const wasmBinary = readFileSync(path.join(wasmDir, 'physics3d.wasm'));
const m = await factory({ wasmBinary });
diff --git a/sdk/tests/sensor-smoke.mjs b/sdk/tests/sensor-smoke.mjs
index d9af666e2..977b03a5a 100644
--- a/sdk/tests/sensor-smoke.mjs
+++ b/sdk/tests/sensor-smoke.mjs
@@ -1,11 +1,10 @@
// Validates that a static sensor detects a (non-sensor) kinematic visitor after the
// enableSensorEvents fix. Run against the freshly built physics wasm.
import { readFileSync } from 'node:fs';
-import { fileURLToPath } from 'node:url';
import path from 'node:path';
+import { requireWasm } from './helpers/wasmDir.mjs';
-const dir = path.dirname(fileURLToPath(import.meta.url));
-const wasmDir = path.resolve(dir, '../../desktop/public/wasm');
+const wasmDir = requireWasm('physics.wasm');
const factory = (await import('file://' + path.join(wasmDir, 'physics.js').replace(/\\/g, '/'))).default;
const m = await factory({ wasmBinary: readFileSync(path.join(wasmDir, 'physics.wasm')) });
diff --git a/sdk/tests/timeline-wasm-integration.test.ts b/sdk/tests/timeline-wasm-integration.test.ts
index 196399b46..fe66c1a68 100644
--- a/sdk/tests/timeline-wasm-integration.test.ts
+++ b/sdk/tests/timeline-wasm-integration.test.ts
@@ -3,7 +3,7 @@
/**
* Integration tests: Timeline property animation applied to real WASM-backed components.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
* Run `node build-tools/cli.js build -t web` first if missing.
*/
import { describe, it, expect, beforeAll } from 'vitest';
diff --git a/sdk/tests/ui-anchor-preset.test.ts b/sdk/tests/ui-anchor-preset.test.ts
index b4749ebdf..f49c1081c 100644
--- a/sdk/tests/ui-anchor-preset.test.ts
+++ b/sdk/tests/ui-anchor-preset.test.ts
@@ -5,7 +5,7 @@
* @brief Anchor presets map to/from UINode box fields, and lay out through the
* real Yoga solver as pinned / centred / stretched.
*
- * The integration half needs pre-built WASM at desktop/public/wasm/esengine.wasm
+ * The integration half needs pre-built WASM at build/wasm/web/esengine.wasm
* (`node build-tools/cli.js build -t web`); the pure half always runs.
*/
import { describe, it, expect, beforeAll } from 'vitest';
diff --git a/sdk/tests/ui-components.test.ts b/sdk/tests/ui-components.test.ts
index 3e975bd31..4f0648272 100644
--- a/sdk/tests/ui-components.test.ts
+++ b/sdk/tests/ui-components.test.ts
@@ -6,7 +6,7 @@
* FlexContainer, Interactable, UIInteraction, Canvas) over
* the real WASM module — CRUD plus the single-pass Yoga layout.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
* Run `node build-tools/cli.js build -t web` first if missing.
*/
import { describe, it, expect, beforeAll } from 'vitest';
diff --git a/sdk/tests/ui-layout-incremental.test.ts b/sdk/tests/ui-layout-incremental.test.ts
index 66fdd6514..6920a6576 100644
--- a/sdk/tests/ui-layout-incremental.test.ts
+++ b/sdk/tests/ui-layout-incremental.test.ts
@@ -16,7 +16,7 @@
* build the same end state in a FRESH registry (which resets the retained
* cache — Registry::instanceId) and require the two to agree exactly.
*
- * Needs pre-built WASM at desktop/public/wasm (`node build-tools/cli.js build -t web`).
+ * Needs pre-built WASM at build/wasm/web (`node build-tools/cli.js build -t web`).
*/
import { describe, it, expect, beforeAll } from 'vitest';
import { UIPositionType, UINode, type UINodeData } from '../src/ui/core/ui-node';
diff --git a/sdk/tests/ui-layout-integration.test.ts b/sdk/tests/ui-layout-integration.test.ts
index fa8d3627d..f38dbe649 100644
--- a/sdk/tests/ui-layout-integration.test.ts
+++ b/sdk/tests/ui-layout-integration.test.ts
@@ -5,7 +5,7 @@
* @brief Integration tests: App.tick() drives the single-pass UINode Yoga
* layout via the real WASM module.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
* Run `node build-tools/cli.js build -t web` first if missing.
*/
import { describe, it, expect, beforeAll } from 'vitest';
diff --git a/sdk/tests/ui-list-view-widget.test.ts b/sdk/tests/ui-list-view-widget.test.ts
index 80a67d80d..81d7b23d6 100644
--- a/sdk/tests/ui-list-view-widget.test.ts
+++ b/sdk/tests/ui-list-view-widget.test.ts
@@ -5,7 +5,7 @@
* @brief Integration tests for the createListView widget factory over the real
* WASM module + full uiPlugin — virtualization, scroll re-mount, dispose.
*
- * Requires pre-built WASM at desktop/public/wasm/esengine.wasm.
+ * Requires pre-built WASM at build/wasm/web/esengine.wasm.
*/
import { describe, it, expect, beforeAll } from 'vitest';
import { App } from '../src/app/app';