diff --git a/.serena/memories/frontend/testing.md b/.serena/memories/frontend/testing.md index ceffa3af2d..396f827071 100644 --- a/.serena/memories/frontend/testing.md +++ b/.serena/memories/frontend/testing.md @@ -7,9 +7,9 @@ Frontend validation: CLJS + React/Rumext + RxJS/Potok; SCSS modules; shared CLJC Frontend unit tests live under `frontend/test/frontend_tests/` and use `cljs.test`. They should be deterministic, avoid DOM/UI integration where possible, and mock side effects such as RPC, storage, timers, or network access. From `frontend/`: -- Full unit test run: `pnpm run test`. -- Focus a frontend CLJS test namespace: `pnpm run test -- --focus frontend-tests.logic.components-and-tokens`. -- Focus one frontend CLJS test var: `pnpm run test -- --focus frontend-tests.logic.components-and-tokens/change-spacing-token-in-main-updates-copy-layout`. +- Full unit test run: `pnpm run test:quiet`. +- Focus a frontend CLJS test namespace: `pnpm run test:quiet -- --focus frontend-tests.logic.components-and-tokens`. +- Focus one frontend CLJS test var: `pnpm run test:quiet -- --focus frontend-tests.logic.components-and-tokens/change-spacing-token-in-main-updates-copy-layout`. - Build test target only: `pnpm run build:test`. - After `pnpm run build:test`, direct compiled runner focus is faster: `node target/tests/test.js --focus frontend-tests.logic.components-and-tokens/change-spacing-token-in-main-updates-copy-layout`. - Watch tests: `pnpm run watch:test`. diff --git a/docs/technical-guide/developer/common.md b/docs/technical-guide/developer/common.md index 4115b51d85..9341f590c4 100644 --- a/docs/technical-guide/developer/common.md +++ b/docs/technical-guide/developer/common.md @@ -294,6 +294,18 @@ pnpm run test -- --focus frontend-tests.logic.components-and-tokens pnpm run test -- --focus frontend-tests.logic.components-and-tokens/change-token-in-main ``` +For non-interactive runs (CI, scripted invocations, agent loops), use the quiet +variant. It runs the same `build:wasm && build:test && node target/tests/test.js` +pipeline but buffers each build step's output and only replays it on failure; +test-runner output streams through normally. Short progress hints +(`Building wasm...`, `Running tests...`) go to `stderr`, so capturing `stdout` +gives you just the test results. + +```bash +# Quiet run (same arguments as `pnpm run test`) +pnpm run test:quiet -- --focus frontend-tests.logic.components-and-tokens +``` + #### Test output The default kaocha reporter outputs a summary for the test run. There is a pair diff --git a/frontend/package.json b/frontend/package.json index 921e0ff02f..289e92c734 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -34,6 +34,7 @@ "lint:scss": "pnpm exec stylelint '{src,resources}/**/*.scss'", "build:test": "clojure -M:dev:shadow-cljs compile test", "test": "pnpm run build:wasm && pnpm run build:test && node target/tests/test.js", + "test:quiet": "node ./scripts/test-quiet.js", "test:storybook": "vitest run --project=storybook", "watch:test": "mkdir -p target/tests && concurrently \"clojure -M:dev:shadow-cljs watch test\" \"nodemon -C -d 2 -w target/tests --exec 'node target/tests/test.js'\"", "test:e2e": "playwright test --project default", diff --git a/frontend/scripts/test-quiet.js b/frontend/scripts/test-quiet.js new file mode 100644 index 0000000000..7b5ad068ae --- /dev/null +++ b/frontend/scripts/test-quiet.js @@ -0,0 +1,30 @@ +import { spawnSync } from "node:child_process"; + +const BUILD_STEPS = [ + { label: "Building wasm", cmd: "pnpm", args: ["run", "build:wasm"] }, + { label: "Building test bundle", cmd: "pnpm", args: ["run", "build:test"] }, +]; + +const progress = (msg) => process.stderr.write(`${msg}\n`); + +for (const step of BUILD_STEPS) { + progress(`${step.label}...`); + const result = spawnSync(step.cmd, step.args, { + stdio: ["ignore", "pipe", "pipe"], + maxBuffer: 64 * 1024 * 1024, + }); + if (result.status !== 0) { + progress(`${step.label} failed`); + if (result.stdout?.length) process.stdout.write(result.stdout); + if (result.stderr?.length) process.stderr.write(result.stderr); + process.exit(result.status ?? 1); + } +} + +progress("Running tests..."); +const result = spawnSync( + "node", + ["target/tests/test.js", ...process.argv.slice(2)], + { stdio: "inherit" }, +); +process.exit(result.status ?? 1);