diff --git a/tests/integration/prepare-assets.test.ts b/tests/integration/prepare-assets.test.ts index 359f944..82924f0 100644 --- a/tests/integration/prepare-assets.test.ts +++ b/tests/integration/prepare-assets.test.ts @@ -6,7 +6,7 @@ import { execFile } from 'node:child_process'; import { promisify } from 'node:util'; import sharp from 'sharp'; import { BarcodeFormat, MultiFormatWriter } from '@zxing/library'; -import { describe, expect, it } from 'vitest'; +import { afterAll, describe, expect, it } from 'vitest'; // @ts-expect-error The production script is native ESM and intentionally has no TypeScript runtime wrapper. import { hashFile } from '../../scripts/lib/hash-file.mjs'; @@ -22,7 +22,16 @@ import { generateSocialPreview } from '../../scripts/generate-social-preview.mjs const execFileAsync = promisify(execFile); interface Candidate { id: string; fileName: string; sha256: string; } -const createRoot = async (): Promise => mkdtemp(join(tmpdir(), 'portfolio-assets-test-')); +const roots: string[] = []; +const createRoot = async (): Promise => { + const root = await mkdtemp(join(tmpdir(), 'portfolio-assets-test-')); + roots.push(root); + return root; +}; + +afterAll(async () => { + await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true }))); +}); const writeJson = async (path: string, value: unknown): Promise => { await writeFile(path, `${JSON.stringify(value, null, 2)}\n`, 'utf8');