Fork me on GitHub
Jacob Emcken10:06:43

I have a .cljc file with reader conditionals in for both Clojure (Java) and ClojureScript (Node). I would like to get inspired from others who are testing both... have you any links to existing public repos doing this in a way you think is good?

vemv10:06:43 does plenty of reader conditionals in test/. I find it a sound approach overall, don't recall problems from it.

Jacob Emcken10:06:25

thanks, gonna take a look

Jacob Emcken12:06:23

What is this file for: I found it confusing to find something outside the test folder which seems to be related to tests.


That's a minor ns, it provides better IDE integration for Cursive users when using (is spec-assertion-thrown?) clojure.test's API is a bit odd about how to extend it (namely with multimethods, which won't play always nicely with IDEs, linters, etc) See also


Take a look at how HoneySQL does this: it's all cljc files and the file runs both clj and cljs tests.


@USW6URK47 do you also will need to test async functions?

Jacob Emcken11:06:41

@U3Y18N0UC not at the moment anyway. I'll cross that bridge when (if) I get there

Jacob Emcken15:06:10

@U45T93RA6 I can get the tests running, and I see the feedback on STDOUT, but "return value" of node target/out/tests.js is the same regardless of success or failure. It doesn't play nice with my CI/CD pipeline.

Jacob Emcken15:06:28

@U04V70XH6 thanks for the pointer to HoneySQL. Sadly for reasons outside things I can change I have to use lein in the foreseeable future for the project I'm working on.


I don't think that's the case. We've paid close attention to the return value of the Node process If I intentionally break a :cljs reader branch, CircleCI will fail as expected:


The magic sauce being IIRC many codebases implement their own flavor of this - you're right that the unix return code is a gotcha, but not an insurmountable one

Jacob Emcken15:06:20

I was looking at this: I must admit I expected less DIY and more "plug this and it works". I guess lein test set my expectations a bit to high when it came to ClojureScript 😄

Jacob Emcken15:06:22

I will take a look at the "magic sauce" 😄


lein test generally hasn't worked well for me for running two targets at once (jvm + node). it's seems 'complected' to me, which is why it's explicitly disabled in project.clj

Jacob Emcken06:06:19

lein test works in my opinion VERY well for Clojure (JVM) only. No hairy setup or knowledge about "test runners" is necessary - it just works as expected. A combined Clojure and ClojureScrip (JVM + node) is an entirely different story - sadly.

👍 2
Jacob Emcken06:06:38

The JVM-only experience had set my expectations very high for a combined project. Expectations that obviously was not met 😅


@USW6URK47 Are you using CLJS with Shadow-CLJS? If so, there's a target called :node-tests that do what you want. If you don't, or can't, use it theres another option like re-defining the summary to exist on the right exit code 😄