From 3c5f730a7e6bd5659faaef05dc5b61e6ff0a5d42 Mon Sep 17 00:00:00 2001 From: Miguel Angel Simon Sierra Date: Sun, 27 Sep 2026 01:05:58 -0400 Subject: [PATCH] test(cli): catalog --installed tests restore cwd and remove their folders --- packages/cli/src/commands/catalog.test.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/catalog.test.ts b/packages/cli/src/commands/catalog.test.ts index da265264bf..1d51dd3e58 100644 --- a/packages/cli/src/commands/catalog.test.ts +++ b/packages/cli/src/commands/catalog.test.ts @@ -1,8 +1,8 @@ // fallow-ignore-file code-duplication -import { mkdtempSync, writeFileSync } from "node:fs"; +import { mkdtempSync, rmSync, writeFileSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { RegistryItem } from "@hyperframes/core"; import { @@ -958,11 +958,17 @@ describe("installedViewLines", () => { }); describe("catalog --installed", () => { + const projects: string[] = []; const inProject = (files: Record) => { const dir = mkdtempSync(join(tmpdir(), "hf-catalog-installed-")); + projects.push(dir); for (const [name, text] of Object.entries(files)) writeFileSync(join(dir, name), text); vi.spyOn(process, "cwd").mockReturnValue(dir); }; + afterEach(() => { + vi.mocked(process.cwd).mockRestore(); + for (const dir of projects.splice(0)) rmSync(dir, { recursive: true, force: true }); + }); it("fails outside a project, as other project commands do, before fetching the registry", async () => { inProject({});