Hi, I am building some e2e tests using nbb, which involves spawning a server, sending requests to it, and checking the responses. It's working great. I am running the tests with cljs.test like this (t/run-tests 'sitefox.e2etests.nbbauth) and that works fine. I would like to generate a report at the end so I am following the instructions on https://clojurescript.org/tools/testing#detecting-test-completion-success but creating this method doesn't seem to do anything. Am I doing something wrong or is this an nbb issue?
(deftest basic-site-test
(t/testing "Basic test of Sitefox on nbb."
(async done
(p/let [server (run-server "examples/nbb" "npm i --no-save; npm run serve" 8000)
res (js/fetch " ")
text (.text res)]
(is (j/get-in server [:process :pid]) "Server is running?")
(is (j/get server :open) "Server port is open?")
(is (j/get res :ok) "Was server response ok?")
(is (includes? text "Hello") "Server response includes 'Hello' text?")
(log "Test done. Killing server.")
(j/call server :kill)))))
(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
(log "Generating test report.")
(if (cljs.test/successful? m)
(println "Success!")
(println "FAIL")))
(t/run-tests 'sitefox.e2etests.nbbauth)
Let me know if there is any further info I can provide. Thanks!Just to clarify "doesn't do anything" - I don't see the output "Generating test report." so it seems the method is not getting called.
Can you test if any of the other methods are called?
AFAIK it should work https://github.com/babashka/sci.configs/blob/3cd48a595bace287554b1735bb378bad1d22b931/src/sci/configs/cljs/test.cljs#L350-L362
This seems to work:
$ ./cli.js -e "(require '[cljs.test :as t]) (t/deftest foo (prn :hello)) (defmethod t/report [:cljs.test/default :end-run-tests] [_] (prn :end)) (t/run-tests *ns*)"
Testing user
:hello
Ran 1 tests containing 0 assertions.
0 failures, 0 errors.
:end: if you have a minimal counter-repro, happy to look
Thank you will investigate further.
PEBCAK. I forgot to call (done) on the async test. Working now, thanks.
👍
Hi. Has anyone tried using rewrite-edn with nbb? When I try requiring borkdude-write.edn, I get an exception Could not resolve symbol: IWithMeta which is coming from https://github.com/clj-commons/rewrite-clj/blob/main/src/rewrite_clj/interop.cljc. I can try to patch nbb’s implements? but figured I’d ask in case there are other reasons why rewrite wouldn’t work with nbb
It does work with bb but only because bb includes rewrite-clj
Gotcha. Would you be interested in a contribution to similarly include it with nbb?
yeah I'd be fine with that
Cool thumbsup_all
joyride has it here: https://github.com/BetterThanTomorrow/joyride/blob/02660dba6f476f79ae2bc4abc21aa2825a8c90d9/src/joyride/sci.cljs#L91 we could move that config to sci.configs and then use that from nbb
also, if you're just interested in logseq-nbb having this, you can do that without changing nbb
True. When I get to this I’ll timebox contributing joyride’s config upstream but if I exceed it I’ll fallback to logseq-nbb
upstreaming the config to sci.configs should directly benefit logseq-nbb as well righ
so why timebox it
anyway, do what you need to do 👍