Fork me on GitHub
#clojurescript
<
2024-07-05
>
Eric13:07:40

Hello This is part of my shadow-cljs.edn file

{:builds
   {:app
      {:asset-path "/js/q",
       ...},
    :tests {:ns-regexp "-test$", :output-to "out/tests.js", :target :karma}},
 :dependencies [...],
 :nrepl {...},
 :source-paths ["src/cljs" "src/cljc" "src/clj" "test/cljs"]}
Is there a way I can have the tests output in different files e.g out/test1.js, out/test2.js?

p-himik14:07:25

A JS file per namespace? You can create multiple test builds, each with its own :output-to and :ns-regexp. Or, if the tests will be run by some JS library/framework, you can probably use module splitting within a single build and export all the test functions.

Eric14:07:49

Am looking to have test coverage report for each test file. Can try the module spliting

p-himik14:07:28

Can it not make coverage report for each test function? Or would that be too granular?

Eric14:07:35

Yeah. That is very granular. Per file will be ideal to me

thheller14:07:30

:karma only outputs a single file. :npm-module has a file per namespace, but no clue how that works with karma

👀 1
Vladimir Pouzanov19:07:32

I'm having a bit of a hard time writing idiomatic code with promisified loop/recur, can someone nudge me in the right direction? (I do have this code wroking with regular promise chains just fine, I only wanted to see if I can make it "neater"). Here's the problem statement: I'm using promesa as my promise-handling library and I'm trying to figure if its loop/recur can recur over promises.

(defn myfn
  [v]
  (println "called myfn with " (str v))
  (if (= v 0) (p/resolved "42!") (p/rejected "bleh")))

(defn err-handler
  [e i]
  (println "err: " (str e))
  #_(p/then (p/delay 1000)
          (do
            (println "will recur")
            (p/recur (dec i))))
  (p/recur (dec i)))

(defn recur-myfn
  [f]
  (p/loop [i 3]
    (p/do
      (println "recur with " i)
      (-> (f i)
          (p/catch #(err-handler % i))))))

(recur-myfn myfn)
The code above works as intended, but if you use the commented out implementation in err-handler, it breaks with a mysterious f.call is not a function. I tried going through the p/loop macro but my clojure skills aren't there yet so I'm getting lost. Overall I don't have to be concerned with the stack depth with the promises, it's just that it seemed that loop/recur code would signal my intent better

✅ 2
p-himik23:07:27

Doesn't p/then expect a function as its second argument?

👀 1
Vladimir Pouzanov09:07:36

thanks! I'm still getting used to programming without types and I'm missing those subtle differences all over the place

Vladimir Pouzanov09:07:43

that was totally it