diff --git a/CLAUDE.md b/CLAUDE.md index bdd735fa01..b83fd0dfa6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -43,16 +43,11 @@ Tests use Bun's Jest-compatible test runner with proper test fixtures: ```typescript import { test, expect } from "bun:test"; -import { - bunEnv, - bunExe, - normalizeBunSnapshot, - tempDirWithFiles, -} from "harness"; +import { bunEnv, bunExe, normalizeBunSnapshot, tempDir } from "harness"; test("my feature", async () => { // Create temp directory with test files - const dir = tempDirWithFiles("test-prefix", { + using dir = tempDir("test-prefix", { "index.js": `console.log("hello");`, }); @@ -60,7 +55,7 @@ test("my feature", async () => { await using proc = Bun.spawn({ cmd: [bunExe(), "index.js"], env: bunEnv, - cwd: dir, + cwd: String(dir), stderr: "pipe", }); diff --git a/test/CLAUDE.md b/test/CLAUDE.md index f0f112ed62..8d63729452 100644 --- a/test/CLAUDE.md +++ b/test/CLAUDE.md @@ -27,11 +27,11 @@ Use `bun:test` with files that end in `*.test.ts`. When spawning Bun processes, use `bunExe` and `bunEnv` from `harness`. This ensures the same build of Bun is used to run the test and ensures debug logging is silenced. ```ts -import { bunEnv, bunExe } from "harness"; +import { bunEnv, bunExe, tempDir } from "harness"; import { test, expect } from "bun:test"; test("spawns a Bun process", async () => { - const dir = tempDirWithFiles("my-test-prefix", { + using dir = tempDir("my-test-prefix", { "my.fixture.ts": ` console.log("Hello, world!"); `, @@ -40,7 +40,7 @@ test("spawns a Bun process", async () => { await using proc = Bun.spawn({ cmd: [bunExe(), "my.fixture.ts"], env: bunEnv, - cwd: dir, + cwd: String(dir), }); const [stdout, stderr, exitCode] = await Promise.all([ @@ -94,15 +94,15 @@ Most APIs in Bun support `port: 0` to get a random port. Never hardcode ports. A Use `tempDirWithFiles` to create a temporary directory with files. ```ts -import { tempDirWithFiles } from "harness"; +import { tempDir } from "harness"; import path from "node:path"; test("creates a temporary directory with files", () => { - const dir = tempDirWithFiles("my-test-prefix", { + using dir = tempDir("my-test-prefix", { "file.txt": "Hello, world!", }); - expect(await Bun.file(path.join(dir.path, "file.txt")).text()).toBe( + expect(await Bun.file(path.join(String(dir), "file.txt")).text()).toBe( "Hello, world!", ); });