This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-16
Channels
- # announcements (62)
- # babashka (12)
- # babashka-sci-dev (73)
- # beginners (16)
- # biff (10)
- # calva (65)
- # cider (13)
- # clerk (8)
- # clojure (31)
- # clojure-europe (16)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-spec (24)
- # clojure-uk (5)
- # clojuredesign-podcast (18)
- # clojurescript (18)
- # dev-tooling (2)
- # emacs (30)
- # etaoin (4)
- # gratitude (3)
- # hyperfiddle (20)
- # integrant (2)
- # jobs (4)
- # kaocha (7)
- # malli (1)
- # observability (11)
- # off-topic (11)
- # pathom (12)
- # podcasts-discuss (7)
- # portal (12)
- # quil (3)
- # re-frame (6)
- # releases (1)
- # sql (22)
- # squint (5)
- # testing (79)
- # tools-deps (3)
- # xtdb (20)
Using cljs.test
, how can I create multiple deftest
based on a collection?
In jest
I could do this:
test.each(routes)("%s", async (route) => { ... }
Where each route is the name of the test.
The problem with setting a single deftest
with multiple assertions (like are
) is pinpointing the exact test that failed.
I think I can do it with a macro, but is there anything built in for it?It does conflict with async testing
https://clojurescript.org/tools/testing#async-testing
*NOTE:* You cannot have more than one async test per deftest form or only the first one will run.
Seems that can wrap all the testing
forms with a single async
form and call done
only when every async route test is done.
Hmm, but it won't work if that async's function body uses other async things since testing
needs for its body to be synchronous.
Some something like this is possible:
(defn some-async-fn [route]
(js/Promise.resolve route))
(defn async-test-fn [route]
(-> (some-async-fn route)
(.then (fn [result]
(t/testing "result is the route"
(t/is (= result route)))))))
(def routes [{:id :route-1} {:id :route-2}])
(t/deftest async-test
(t/async done
(let [promises (mapv async-test-fn routes)]
(-> (js/Promise.all promises)
(.then (fn [_]
(done)))))))
Hey, i’m using cljs-test,
Inside a test, I have some promise that i’m using <p!
to await for it.
The promise is failing and i’m getting the error:
dev/out/cljs-runtime/cljs/core.cljs:11623
(let [e (js/Error. message)]
^
Error: Promise error
at new cljs$core$ExceptionInfo
anyone knows why the error isn’t printed?
Thanks 🙏Is there some way I configure myself out of this problem?
[JSC_UNTRANSPILABLE] Cannot convert ECMASCRIPT_2018 feature "RegExp Lookbehind" to targeted output language.
Is this outdated? https://clojurescript.org/reference/compiler-options#language-in-and-language-out