diff --git a/common/test/common_tests/runner.cljc b/common/test/common_tests/runner.cljc index 8243eb1c4c..61d9f9f92e 100644 --- a/common/test/common_tests/runner.cljc +++ b/common/test/common_tests/runner.cljc @@ -7,6 +7,7 @@ (ns common-tests.runner (:require #?(:clj [common-tests.fressian-test]) + #?(:cljs ["node:fs" :as fs]) #?(:cljs [app.common.logging :as l]) #?(:cljs [clojure.string :as str]) #?(:cljs [clojure.tools.cli :refer [parse-opts]]) @@ -137,7 +138,8 @@ [common-tests.variant-test])) (def test-namespaces - [#?(:clj 'common-tests.fressian-test) + [#?(:cljs 'common-tests.runner) + #?(:clj 'common-tests.fressian-test) 'common-tests.attrs-test 'common-tests.buffer-test 'common-tests.colors-test @@ -305,14 +307,23 @@ (defn- usage [summary] - (str "Usage: pnpm run test:js -- [options]\n\n" + (str "Usage: pnpm run test -- [options]\n\n" "Options:\n" summary "\n\n" "Focus examples:\n" - " pnpm run test:js -- --focus common-tests.logic.comp-sync-test\n" - " pnpm run test:js -- --focus common-tests.logic.comp-sync-test/test-sync-when-changing-attribute\n\n" + " pnpm run test -- --focus common-tests.logic.comp-sync-test\n" + " pnpm run test -- --focus common-tests.logic.comp-sync-test/test-sync-when-changing-attribute\n\n" "Log level example (quiets app logging during the run):\n" - " pnpm run test:js -- --focus common-tests.logic.comp-sync-test --log-level warn")) + " pnpm run test -- --focus common-tests.logic.comp-sync-test --log-level warn")) + + (t/deftest runner-usage-uses-existing-package-scripts + (let [package (js/JSON.parse (.readFileSync fs "package.json" "utf8")) + scripts (.-scripts package) + commands (re-seq #"pnpm run ([\w:-]+)" (usage ""))] + (t/is (seq commands)) + (doseq [[_ command] commands] + (t/is (some? (gobj/get scripts command)) + (str "Unknown package script in runner help: " command))))) (defn- fail! [message] diff --git a/docs/technical-guide/developer/common.md b/docs/technical-guide/developer/common.md index e9bf7bda43..8f3de64dfe 100644 --- a/docs/technical-guide/developer/common.md +++ b/docs/technical-guide/developer/common.md @@ -282,20 +282,20 @@ Common tests can also be run in the JavaScript runtime with shadow-cljs. From ```bash # To run all common JavaScript tests once -pnpm run test:js +pnpm run test # Quiet run for non-interactive output pnpm run test:quiet # To run a single common JavaScript tests module -pnpm run test:quiet -- --focus common-tests.logic.comp-sync-test +pnpm run test -- --focus common-tests.logic.comp-sync-test # To run a single common JavaScript test and quiet app-level logging -pnpm run test:quiet -- --focus common-tests.logic.comp-sync-test/test-sync-when-changing-attribute --log-level warn +pnpm run test -- --focus common-tests.logic.comp-sync-test/test-sync-when-changing-attribute --log-level warn ``` The common JavaScript runner accepts the same forwarded runner arguments through -pnpm run test:js -- ..., +pnpm run test -- ..., pnpm run test:quiet -- ..., or directly through node target/tests/test.js ... after pnpm run build:test. Supported runner arguments @@ -539,4 +539,3 @@ instead of ids: ``` You can see more examples of usage by looking at the existing unit tests. -