mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
🐛 Correct common test runner usage
Show the existing interactive test command in help and documentation, and check that help only names package scripts that exist. AI-assisted-by: gpt-6.1-terra
This commit is contained in:
parent
a3df3cafae
commit
a90e5d799e
@ -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]
|
||||
|
||||
@ -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
|
||||
<code class="language-text">pnpm run test:js -- ...</code>,
|
||||
<code class="language-text">pnpm run test -- ...</code>,
|
||||
<code class="language-text">pnpm run test:quiet -- ...</code>, or directly through
|
||||
<code class="language-text">node target/tests/test.js ...</code> after
|
||||
<code class="language-text">pnpm run build:test</code>. Supported runner arguments
|
||||
@ -539,4 +539,3 @@ instead of ids:
|
||||
```
|
||||
|
||||
You can see more examples of usage by looking at the existing unit tests.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user