import { expect, spyOn, test } from "bun:test"; import { join } from "node:path"; import { loadPlugins } from "../src/registry.ts"; const dir = join(import.meta.dir, "fixtures/plugins"); test("registry loads echo plugin and skips broken one", async () => { const warn = spyOn(console, "warn").mockImplementation(() => {}); const reg = await loadPlugins([dir, join(dir, "does-not-exist")]); expect(reg.list().map((m) => m.id)).toEqual(["echo"]); expect(reg.get("echo")?.manifest.name).toBe("Echo"); expect(reg.get("broken")).toBeUndefined(); expect(warn.mock.calls.some((c) => String(c[0]).includes("broken"))).toBe(true); await reg.reload(); expect(reg.list()).toHaveLength(1); warn.mockRestore(); }); test("duplicate ids across dirs keep the first", async () => { const warn = spyOn(console, "warn").mockImplementation(() => {}); const reg = await loadPlugins([dir, dir]); expect(reg.list()).toHaveLength(1); warn.mockRestore(); });