Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(test): dispose PlayOnboard instances so a leaked 650ms timer can't crash vitest teardown

nirholas2841ab5df98a
diff --git a/tests/play-onboard-controls.test.js b/tests/play-onboard-controls.test.js
index b1e4a184c..fef7006a5 100644
--- a/tests/play-onboard-controls.test.js
+++ b/tests/play-onboard-controls.test.js
@@ -13,7 +13,7 @@
// coincommunities.js and asserts the panel covers it, which means the next
// binding added there fails here instead of quietly going undocumented.
-import { describe, it, expect, beforeEach } from 'vitest';
+import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
import { PlayOnboard } from '../src/game/play-onboard.js';
@@ -33,8 +33,15 @@ function readPanel() {
return { keys, groups, text: panel.textContent };
}
+// Every instance arms a 650ms first-visit timer in its constructor; an
+// undisposed one fires after jsdom teardown and crashes the vitest run
+// (`document is not defined`) even with every test green, so each test's
+// instances are disposed in afterEach.
+const instances = [];
+
function openPanel() {
const ob = new PlayOnboard({ coin: COIN });
+ instances.push(ob);
document.querySelector('.po-ctrl-btn').click();
return ob;
}
@@ -58,6 +65,10 @@ beforeEach(() => {
try { localStorage.clear(); } catch { /* jsdom without storage */ }
});
+afterEach(() => {
+ while (instances.length) instances.pop().dispose();
+});
+
describe('/play controls reference', () => {
it('opens from the always-visible strip', () => {
expect(document.querySelector('#po-help')).toBeNull();