This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-29
Channels
- # announcements (1)
- # beginners (176)
- # biff (3)
- # calva (7)
- # clojure (68)
- # clojure-europe (18)
- # clojure-nl (1)
- # clojure-norway (12)
- # clojure-uk (6)
- # community-development (4)
- # conjure (1)
- # core-async (5)
- # datomic (21)
- # events (1)
- # fulcro (5)
- # funcool (3)
- # hyperfiddle (35)
- # leiningen (18)
- # malli (3)
- # nbb (20)
- # overtone (20)
- # pedestal (1)
- # polylith (68)
- # portal (6)
- # releases (1)
- # shadow-cljs (6)
- # slack-help (7)
- # squint (6)
- # vim (4)
- # xtdb (4)
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.
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:
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
Gotcha. Would you be interested in a contribution to similarly include it with nbb?
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