Skip to content

The fastest browser for AI agents to run browser automation, built for sharing your logged-in browser state with your AI agents, like Codex or Claude Code, without disturbing you. Zero cost, zero config.

Add eval-module regression test for the shipped bundle

0x08bfc2228dd47
diff --git a/package/ego-browser/src/help-runtime.test.mjs b/package/ego-browser/src/help-runtime.test.mjs
index f852955..2716900 100644
--- a/package/ego-browser/src/help-runtime.test.mjs
+++ b/package/ego-browser/src/help-runtime.test.mjs
@@ -1,5 +1,9 @@
import test from "node:test";
import assert from "node:assert/strict";
+import { spawnSync } from "node:child_process";
+import { readFileSync } from "node:fs";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
import { help, formatHelp } from "../dist/src/help-runtime.js";
@@ -37,3 +41,32 @@ test("formatHelp renders the signature for an embedded doc", () => {
const text = formatHelp(doc);
assert.ok(text.includes("click("), `expected signature in:\n${text}`);
});
+
+test("help works when the shipped bundle runs as an eval module", () => {
+ // The app executes the SDK from an in-memory string, so its import.meta.url
+ // ("file:///...[eval1]") is not a readable file — the exact condition that
+ // broke the old self-introspection. Feed the real dist/out bundle to node
+ // the same way and query help through the installed global, like an agent
+ // script (a separate eval module sharing only globals) would. The file://
+ // imports above cannot catch a regression of this class.
+ const root = dirname(dirname(fileURLToPath(import.meta.url)));
+ const bundle = readFileSync(join(root, "dist", "out", "index.js"), "utf-8");
+ // globalThis, not a bare identifier: appended source shares the bundle's
+ // module scope, where the raw help(helpers, ...names) export would shadow
+ // the installed global wrapper.
+ const probe = 'console.log(globalThis.help("click"))';
+ const result = spawnSync(process.execPath, ["--input-type=module"], {
+ input: `${bundle}\n${probe}\n`,
+ encoding: "utf-8",
+ timeout: 30_000,
+ });
+ assert.equal(result.status, 0, result.stderr);
+ assert.ok(
+ !result.stdout.includes("Unknown helper"),
+ `docs map was empty under eval loading:\n${result.stdout}`,
+ );
+ assert.ok(
+ result.stdout.includes("click("),
+ `expected the click signature in:\n${result.stdout}`,
+ );
+});