diff --git a/.serena/memories/frontend/testing.md b/.serena/memories/frontend/testing.md index 396f827071..c5edd61f87 100644 --- a/.serena/memories/frontend/testing.md +++ b/.serena/memories/frontend/testing.md @@ -10,6 +10,7 @@ From `frontend/`: - 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`. +- Quiet `app.*` logging during a run: append `--log-level warn` (or `trace|debug|info|warn|error`). - 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 9341f590c4..6393bdacd6 100644 --- a/docs/technical-guide/developer/common.md +++ b/docs/technical-guide/developer/common.md @@ -292,6 +292,9 @@ pnpm run test -- --focus frontend-tests.logic.components-and-tokens # To run a single frontend test pnpm run test -- --focus frontend-tests.logic.components-and-tokens/change-token-in-main + +# To quiet app-level logging during the run (trace|debug|info|warn|error) +pnpm run test -- --focus frontend-tests.logic.components-and-tokens --log-level warn ``` For non-interactive runs (CI, scripted invocations, agent loops), use the quiet diff --git a/frontend/test/frontend_tests/runner.cljs b/frontend/test/frontend_tests/runner.cljs index 152d4466bc..3112ed0a73 100644 --- a/frontend/test/frontend_tests/runner.cljs +++ b/frontend/test/frontend_tests/runner.cljs @@ -1,5 +1,6 @@ (ns frontend-tests.runner (:require + [app.common.logging :as l] [cljs.test :as t] [clojure.string :as str] [clojure.tools.cli :refer [parse-opts]] @@ -93,8 +94,14 @@ (assert (every? find-ns-obj test-namespaces) "test-namespaces contains a namespace that isn't required in runner.cljs") +(def ^:private log-levels + #{:trace :debug :info :warn :error}) + (def cli-options [["-f" "--focus FOCUS" "Run one test namespace or one test var, e.g. frontend-tests.logic.components-and-tokens/change-token-in-main"] + ["-l" "--log-level LEVEL" "Set app logger level: trace|debug|info|warn|error" + :parse-fn keyword + :validate [log-levels "must be one of trace, debug, info, warn, error"]] ["-h" "--help"]]) (defn- argv @@ -114,7 +121,9 @@ summary "\n\n" "Focus examples:\n" " pnpm run test -- --focus frontend-tests.logic.components-and-tokens\n" - " pnpm run test -- --focus frontend-tests.logic.components-and-tokens/change-token-in-main")) + " pnpm run test -- --focus frontend-tests.logic.components-and-tokens/change-token-in-main\n\n" + "Log level example (quiets app logging during the run):\n" + " pnpm run test -- --focus frontend-tests.logic.groups-test --log-level warn")) (defn- fail! [message] @@ -218,8 +227,10 @@ (println (usage summary)) (.exit js/process 0)) - (:focus options) - (run-focused-test! (:focus options)) - :else - (run-test-vars! (map #(selected-tests {:ns %}) test-namespaces))))) + (do + (when-let [level (:log-level options)] + (l/setup! {:app level})) + (if (:focus options) + (run-focused-test! (:focus options)) + (run-test-vars! (map #(selected-tests {:ns %}) test-namespaces)))))))