Hi, I just setup testing with figwheel, according to the docs. It's working well for the most part, except that when I add a new deftest, it isn't picked up on recompile. Only the tests that existed on initial compilation are detected. Changes to detected tests are picked up on recompile, but new tests are not. Is this expected, or what might be amiss?

bhauman 2020-07-27T20:10:03.138600Z

@jyee117 what kind of testing are you doing?

bhauman 2020-07-27T20:10:17.138900Z

the :auto-testing ?


I'm using :extra-main-files config option, with a test-runner namespace that executes tests using (figwheel.main.testing/run-tests (cljs-test-display.core/init! "app-testing"))

bhauman 2020-07-27T20:14:49.141700Z

OK and you are adding a new test to an existing namespace and you are saying its not detected?

bhauman 2020-07-27T20:15:05.142200Z

is it a simple test or is it asynchronous?

bhauman 2020-07-27T20:15:57.143200Z

like if you add a (deftest new-test (is (= 1 2))) to an existing namespace you are saying it doesn’t get run?


That's correct, adding a simple test like your example isn't run. But the testing namespace has existing tests that are run, and changes to those tests are shown.


I'm also running figwheel via the API. So I start a lein repl and then start figwheel with => (fig), which calls (start {:mode :serve} "dev") (cljs-repl "dev).

bhauman 2020-07-27T20:29:43.148100Z

@jyee117 OK I took a look at the code

bhauman 2020-07-27T20:30:02.148500Z

I may have to try an example

bhauman 2020-07-27T20:30:21.149Z

@jyee117 what are the figwheel options your are using?

bhauman 2020-07-27T20:30:47.149400Z

because you need CLJ reloading for new tests to get picked up

bhauman 2020-07-27T20:31:21.149700Z

oh wait no thats wrong

bhauman 2020-07-27T20:31:38.150100Z

the main thing is that your runner namespace needs to be recompiled

bhauman 2020-07-27T20:31:51.150500Z

and reloaded

bhauman 2020-07-27T20:32:44.151400Z

so the :recompile-dependents cljs option has to be true , which is the default I think


That's probably it, I have :recompile-dependents set to false for better performance. I'll test that out now.

borkdude 2020-07-27T20:44:53.153300Z

Good news, my work is now compiling CLJS using figwheel.main in dev and cljs.main for production. Been using boot since the inception of the project, but now we're doing hybrid build.

bhauman 2020-07-27T20:46:48.153900Z

@borkdude fantastic!

bhauman 2020-07-27T20:47:36.154500Z

that should be a big improvement

bhauman 2020-07-27T20:48:39.155300Z

@jyee117 the problem is that run-tests relies on macro expansion during compilation to incorporate the new tests

borkdude 2020-07-27T20:51:18.155500Z

We're using this babashka script to run 3 processes (CLJS, less and CLJ) in one terminal for development: Unfortunately only one REPL gets to interact with stdin in this way. Not sure if it's still possible to get access to the CLJS REPL, maybe via the running process on port 9500?

bhauman 2020-07-27T20:52:04.155800Z

@borkdude nah it doesn’t work like that

borkdude 2020-07-27T20:52:47.156Z

I guessed so, it's rebel readline right?

borkdude 2020-07-27T20:53:11.156200Z

Anyway, we can also just run the three processes separately. no problem

bhauman 2020-07-27T20:53:13.156400Z

yeah, but that’s not important, you can skip rebel-readline

bhauman 2020-07-27T20:53:35.156600Z

its best to connect to the CLJS repl through your editor

bhauman 2020-07-27T20:53:38.156800Z


borkdude 2020-07-27T20:53:53.157Z

how does one do this? I guessed this should be done using inf-clojure interacting on stdin?

bhauman 2020-07-27T20:54:02.157200Z


bhauman 2020-07-27T20:54:21.157400Z

the best way is with nrepl

bhauman 2020-07-27T20:54:27.157600Z

and piggieback

bhauman 2020-07-27T20:54:43.157800Z

most editors speak that language

bhauman 2020-07-27T20:54:54.158Z

cider for emacs

borkdude 2020-07-27T20:55:36.158200Z

yeah, I had that in the previous setup, so I'm familiar with it, but too lazy to actually start it. the figwheel REPL just opens itself, which is kinda neat 😉

bhauman 2020-07-27T20:55:41.158400Z

but you would have to start an nREPL process that includes cider in your figwheel process

bhauman 2020-07-27T20:56:09.158600Z

I mean includes piggieback and cider

bhauman 2020-07-27T20:56:17.158800Z

cool you got it

borkdude 2020-07-27T20:56:34.159Z

am I right that without the -r option I also don't get reloading?

bhauman 2020-07-27T20:56:43.159200Z


borkdude 2020-07-27T20:57:04.159400Z

so the REPL is coupled to the reloading?

bhauman 2020-07-27T20:57:09.159600Z

you have to have the -r option unless you start figwheel with the api

bhauman 2020-07-27T20:57:17.159800Z

yes the REPL is the connection

borkdude 2020-07-27T20:57:51.160Z

ok, then our config makes sense.

:cljs/dev {:extra-deps
                      {com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
                       com.bhauman/figwheel-main {:mvn/version "0.2.11"}
                      :extra-paths ["src-cljs-dev"]
                      :main-opts ["-m" "figwheel.main" "-co" "common.cljs.edn"
                                  "-d" "frontend/public/js/app.out"
                                  "-o frontend/public/js/app.js"
                                  "-c" "<|>"

borkdude 2020-07-27T20:59:05.160300Z

we also use it for CSS reloading

borkdude 2020-07-27T20:59:29.160500Z

using this for CSS:

:less/dev {:extra-deps
                      {deraen/less4clj {:mvn/version "0.7.4"}}
                      :main-opts ["-m" "less4clj.main"
                                  "--source-paths" "resources/public/css" "--target-path" "frontend/public/css"]}

bhauman 2020-07-27T20:59:46.160700Z

but you don’t need rebel-readline-cljs ?

bhauman 2020-07-27T20:59:57.160900Z

yeah the less bit is cool

borkdude 2020-07-27T21:00:00.161100Z

yeah, I guess so, I just copied that from the figwheel docs

bhauman 2020-07-27T21:00:16.161300Z

yeah you don’t need it

bhauman 2020-07-27T21:00:22.161500Z

it will start faster without it

borkdude 2020-07-27T21:00:35.161700Z

I'll remove it then, thanks for the advice.

bhauman 2020-07-27T21:01:25.161900Z

I saw your tweet where you were dancing with the bird, I think, I freaking loved that

borkdude 2020-07-27T21:02:28.162100Z

haha, thanks. my twitter account got blocked a week or so ago, because of that video, which contained copyrighted music


@bhauman New tests are indeed picked up on recompile when :recompile-dependentsis set to true. I may have to dig deeper into alternative strategies if that slows things down too much, but I'll probably just toggle it as needed for now. Thanks for the help!

bhauman 2020-07-27T21:08:18.165Z

@jyee117 you can run two different builds if it get’s too much

bhauman 2020-07-27T21:08:53.165300Z

oh crap, well it was worth it for sure

athomasoriginal 2020-07-27T21:09:11.165500Z

@borkdude So instead of running clj commands manually, you run that dev script using bb to set everything up. Cool approach. Thanks for sharing!

borkdude 2020-07-27T21:14:54.165700Z

that's right @tkjone

borkdude 2020-07-27T21:15:19.165900Z

and you get to interact with one of those three via stdin as well

borkdude 2020-07-27T21:19:41.166200Z

I could enhance that script by prefixing the output from each process with some string like ---- less : or something so the outputs are more distinguishable


@bhauman I'm looking at background builds, which look like a nice way to do this. Thanks for the tip~

bhauman 2020-07-27T21:39:49.170600Z

quite frankly a seperate test.cljs.edn file works much better and is more predictable