update CLAUDE.md

This commit is contained in:
Jarred Sumner
2025-09-03 03:39:31 -07:00
parent f78d197523
commit d42f536a74
2 changed files with 9 additions and 14 deletions

View File

@@ -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",
});

View File

@@ -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!",
);
});