Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

793 B
Raw Blame
import { builtinEnvironments } from 'vitest/runtime';
import { observeTestProcesses } from './lib/testProcessAttribution.js';

// Keep the observer in Node's environment realm: client transforms replace
// import.meta.url with HTTP URLs. Environment teardown also runs for skipped
// suites and failed collection, unlike an afterAll observer cleanup.
export default {
  ...builtinEnvironments['happy-dom'],
  name: 'portos-observed-happy-dom',
  async setup(global, options) {
    const environment = await builtinEnvironments['happy-dom'].setup(global, options);
    const dispose = observeTestProcesses(() => global.__vitest_worker__?.filepath);
    return {
      async teardown() {
        try { dispose(); }
        finally { await environment.teardown(global); }
      },
    };
  },
};