Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/server/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ for Cloudflare bindings.
bindings (`secrets: { TOKEN_SIGNING_KEY, … }` in the `phase*` integration
tests), and `env.test.ts` drives `loadDwkEnv({ cwd })` against temp dirs, so
no secret file is needed locally or in CI. Add a new test's secrets inline
the same way. One leak: `cli.test.ts` calls `main()`, whose `loadDwkEnv()`
reads `.env`/`<domain>.env` from the working directory, so a local `.env`
there lands in `process.env` during that file.
the same way. `main()` calls `loadDwkEnv()` against `process.cwd()`, so
`cli.test.ts` runs every `main` case from an empty temp dir; keep new `main`
tests inside that `describe`.
13 changes: 12 additions & 1 deletion packages/server/src/cli.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, it, expect, afterAll } from "vitest";
import { describe, it, expect, afterAll, beforeEach, afterEach } from "vitest";
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
Expand Down Expand Up @@ -150,6 +150,17 @@ describe("dwk-serve CLI", () => {
});

describe("main", () => {
// main() calls loadDwkEnv() against process.cwd(); run every case from an
// empty temp dir so a developer's local .env never reaches these tests.
let prevCwd: string;
beforeEach(() => {
prevCwd = process.cwd();
process.chdir(workdir());
});
afterEach(() => {
process.chdir(prevCwd);
});

it("parses args, loads the config path, and starts listening", async () => {
const path = configFile(pingConfig());
const cap = capture();
Expand Down
Loading