diff --git a/package.json b/package.json index 12dc7b70..2d2a21a4 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "pnpm run typecheck && pnpm -r --if-present run build", "typecheck:libs": "tsc --build", "typecheck": "pnpm run typecheck:libs && pnpm -r --filter \"./artifacts/**\" --filter \"./scripts\" --if-present run typecheck", - "test": "pnpm --filter @workspace/api-server test && pnpm --filter @workspace/tx-os test:e2e" + "test": "pnpm --filter @workspace/api-server test && pnpm --filter @workspace/scripts test && pnpm --filter @workspace/tx-os test:e2e" }, "private": true, "devDependencies": { diff --git a/scripts/package.json b/scripts/package.json index f6894bfe..cdaaeef1 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -7,7 +7,8 @@ "hello": "tsx ./src/hello.ts", "seed": "tsx ./src/seed.ts", "remove-chat": "tsx ./src/remove-chat.ts", - "typecheck": "tsc -p tsconfig.json --noEmit" + "typecheck": "tsc -p tsconfig.json --noEmit", + "test": "node --test 'tests/**/*.test.mjs'" }, "dependencies": { "@workspace/db": "workspace:*", diff --git a/scripts/tests/local-setup.test.mjs b/scripts/tests/local-setup.test.mjs index 960005a1..74f1851c 100644 --- a/scripts/tests/local-setup.test.mjs +++ b/scripts/tests/local-setup.test.mjs @@ -7,6 +7,12 @@ import { mkdtempSync, writeFileSync, readFileSync, copyFileSync, mkdirSync, exis import { spawnSync } from "node:child_process"; import { tmpdir } from "node:os"; import path from "node:path"; +import { fileURLToPath } from "node:url"; + +// Resolve the real local-setup.sh from this test file's location so the +// test works regardless of pnpm/node cwd. +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const LOCAL_SETUP_SH = path.resolve(__dirname, "..", "local-setup.sh"); function runLocalSetup(projectDir, extraEnv = {}) { const stubDir = path.join(projectDir, ".stub-bin"); @@ -65,7 +71,7 @@ function makeFakeProject() { mkdirSync(path.join(dir, "scripts"), { recursive: true }); // Copy the script under test verbatim. copyFileSync( - path.resolve("scripts/local-setup.sh"), + LOCAL_SETUP_SH, path.join(dir, "scripts", "local-setup.sh"), ); chmodSync(path.join(dir, "scripts", "local-setup.sh"), 0o755);