Fork me on GitHub
#clojurescript
<
2019-09-24
>
andrea.crotti16:09:23

is there a way to generate test coverage reports for Clojurescript code?

andrea.crotti16:09:16

it's quite easy on the jvm but I can't find anything for Clojurescript

sova-soars-the-sora16:09:18

hmm testing? like a result file with how all the tests went?

andrea.crotti16:09:26

but for Clojurescript. It's a lot more difficult since it's compiled to JS, but in theory we have source maps and there are many JS tools to generate the report

andrea.crotti16:09:46

the fact that I find nothing googling around makes me think it's not going to be easy

lilactown17:09:17

one might be able to leverage self-hosted CLJS to create a cloverage-like tool

lilactown17:09:40

but that assumes the code you’re covering can be run in self-hosted, which isn’t always the case

andy.fingerhut17:09:32

Since you mentioned self-hosted, if I have a ClojureScript library (core.rrb-vector in particular is on my mind, since I've been doing bug fixed for it recently), is there some command or three one can run to determine whether a library supports self-hosted, and if not, what parts of the code are stopping that?

lilactown17:09:50

typically self-hosted breaks on macros that requires and/or uses part of the JVM

lilactown17:09:50

e.g. a macro that calls a function that uses Integer/parseInt

lilactown17:09:05

there’s not really a good way to determine that, other than to load the code and inspect the error 😕

lilactown17:09:51

it can often be pretty deep in your dependencies too… like a macro that calls some library that uses some library that calls a Java method

andy.fingerhut17:09:47

Are there instructions you know of for attempting to load a library in a self-hosted cljs environment? I doubt it is difficult -- just have never done it.

andy.fingerhut17:09:04

Hmm, I found and am reading through https://clojurescript.org/guides/self-hosting to see if I can learn from there.

lilactown17:09:11

using lumo or planck might be enough

andrea.crotti18:09:33

One thing that helps with the coverage issue is to have as much code as possible in cljc files

andrea.crotti18:09:32

Which means you can use cloverage as usual and you get frontend coverage for free in a way. You can get quite far with that but would be nice to get the rest

andy.fingerhut18:09:33

According to this Wikipedia page on the Spidermonkey JS runtime, version 1.8.5 was first released in 2011, and there have been new versions released every year. Is it a little odd that on a Mac brew install spidermonkey installs that old version?

lilactown18:09:27

if no one is actively maintaining that brew, then it might not be up to date

andy.fingerhut18:09:54

Sure. Just kinda weird in a sea of packages that do seem pretty up to date. I recently got a new Mac and decided to try Homebrew instead of MacPorts to see if I was missing out. That and there is a brew install clojure for the new Clojure CLI tools, but nothing like that for MacPorts.

lilactown19:09:02

Yeah. I don't think people are often doing much dev with spidermonkey tbh

lilactown19:09:47

My bet would be Apple's jscore is used way more. v8 (due to node) probably more than that

lilactown19:09:31

I use brew and 90% of packages I want are on there, and if a project is actively maintained it usually will end up there