ClojureScript support for the test middleware.
ClojureScript tests can only run in the JS runtime, and eval is the only way
to reach it. So, much like the Clojure path drives execution through eval for
interruptibility, here we rewrite the test op into an eval op that runs the
tests via cljs.test in the runtime, capturing each assertion as EDN-safe data
(see cider.nrepl.cljs.test), then reshape that data into the very same report
the Clojure path produces. See clojure-emacs/cider#555.
Asynchronous (cljs.test/async) tests are awaited by polling the runtime for
the :end-run-tests event (a single eval can't block the JS event loop), up to
an optional :timeout. Other limitations: fail-fast is ignored (cljs.test
has no equivalent); running specific vars runs (but only reports) their whole
namespace, since fixtures are namespace-scoped; and concurrent test runs
sharing one ClojureScript runtime aren't isolated (the reporter state and the
JVM-side results store are global).
ClojureScript support for the test middleware. ClojureScript tests can only run in the JS runtime, and `eval` is the only way to reach it. So, much like the Clojure path drives execution through `eval` for interruptibility, here we rewrite the test op into an `eval` op that runs the tests via `cljs.test` in the runtime, capturing each assertion as EDN-safe data (see `cider.nrepl.cljs.test`), then reshape that data into the very same report the Clojure path produces. See clojure-emacs/cider#555. Asynchronous (`cljs.test/async`) tests are awaited by polling the runtime for the `:end-run-tests` event (a single eval can't block the JS event loop), up to an optional `:timeout`. Other limitations: `fail-fast` is ignored (`cljs.test` has no equivalent); running specific vars runs (but only reports) their whole namespace, since fixtures are namespace-scoped; and concurrent test runs sharing one ClojureScript runtime aren't isolated (the reporter state and the JVM-side results store are global).
(handle-test-cljs handler {:keys [op] :as msg})Handle a test op against an active ClojureScript REPL. Returns true when the op was handled here, nil otherwise (so the caller can fall through).
Handle a test op against an active ClojureScript REPL. Returns true when the op was handled here, nil otherwise (so the caller can fall through).
An atom holding the most recent ClojureScript test results, keyed by namespace
and var, mirroring the Clojure path's store so retest can re-run failures.
An atom holding the most recent ClojureScript test results, keyed by namespace and var, mirroring the Clojure path's store so `retest` can re-run failures.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |