From c47f84348a7ac99107b280660a2d89d646ea40b2 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Sun, 18 Jan 2026 14:07:24 -0800 Subject: [PATCH] Update CLAUDE.md --- test/CLAUDE.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/CLAUDE.md b/test/CLAUDE.md index 763b9d4fb2..7921d35b4d 100644 --- a/test/CLAUDE.md +++ b/test/CLAUDE.md @@ -215,6 +215,30 @@ test("handles errors", async () => { }); ``` +### Avoid dynamic import & require + +**Only** use dynamic import or require when the test is specifically testing something relataed to dynamic import or require. Otherwise, **always use module-scope import statements**. + +**BAD, do not do this**: + +```ts +test("foo", async () => { + // BAD: Unnecessary usage of dynamic import. + const { readFile } = await import("node:fs"); + + expect(await readFile("ok.txt")).toBe(""); +}); +``` + +**GOOD, do this:** + +```ts +import { readFile } from "node:fs"; +test("foo", async () => { + expect(await readFile("ok.txt")).toBe(""); +}); +``` + ### Test Utilities - Use `describe.each()` for parameterized tests