kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
miikka 2020-08-21T06:25:16.015600Z

Hey @plexus, did you create another a cljs test runner that is not Kaocha? I have vague recollection of this but now can't find anything

borkdude 2020-08-21T06:41:24.017300Z

@miikka personally I’ve been using cljs-test-runner by Olical

borkdude 2020-08-21T06:41:54.018Z

Which mimics the Cognitect labs test runner

plexus 2020-08-21T08:33:04.018300Z

@miikka you're thinking of Chui

plexus 2020-08-21T08:33:42.018700Z

@borkdude those aren't test runners, they are test runner proof of concepts πŸ˜›

borkdude 2020-08-21T08:34:17.018900Z

works for me

miikka 2020-08-21T08:52:47.019400Z

Yes, Chui!

plexus 2020-08-21T08:53:49.020100Z

which is really just a piece of the puzzle for kaocha-cljs2, but it can also be used standalone, or be a library for other cljs test tooling

plexus 2020-08-21T08:54:50.020800Z

I've put a lot more work into kaocha-cljs2 the past few weeks as well, including figuring out how it'll work outside of shadow-cljs.

plexus 2020-08-21T08:59:28.021100Z

but it relies on https://clojure.atlassian.net/browse/CLJS-3276 which might take some time to get merged

borkdude 2020-08-21T09:03:32.021800Z

@plexus Cool, so CLJS-3276 will allow more dynamic forms of require at compile time (e.g. using env vars etc.)?

plexus 2020-08-21T09:04:18.022300Z

you can use env vars already

borkdude 2020-08-21T09:04:48.022700Z

I thought CLJS only processes top level require forms outside ns. So how does one do that?

plexus 2020-08-21T09:05:39.023500Z

ah yeah no you're right, if you want to generate a require statement with a macro (which may check env vars) then you need this

borkdude 2020-08-21T09:05:53.024Z

yep, so that's neat to have

borkdude 2020-08-21T09:06:17.024900Z

I'm doing something very similar to CLJS right now in babashka for creating uberscripts. But CLJS-3276 might be cool to support there as well

plexus 2020-08-21T09:06:58.025600Z

currently ClojureScript starts from the top of the files, if it finds an ns form it uses that, if it finds require statements it reads them until it finds some non require statement and then merges them as if it's a single ns form

plexus 2020-08-21T09:07:14.026100Z

(technically I think you could have requires followed by an ns, but not the other way around)

borkdude 2020-08-21T09:07:31.026700Z

Ah, I thought it supported additional requires after the ns form

plexus 2020-08-21T09:08:28.027700Z

so this patch does two things, it continues reading after ns to see if it finds require statements there, or if it finds another form it check if its a macro (based on the previous ns form), if so it loads the macro, analyzes it, and if it turns into a require it processes it

plexus 2020-08-21T09:09:24.028700Z

making sure the macro is able to be expanded is the most tricky part because normally loading macros happens in a later pass... I managed to work around it but waiting for David to tell me if this solution is acceptable or if he has other ideas for how to tackle it

borkdude 2020-08-21T09:09:41.028900Z

:thumbsup:

plexus 2020-08-21T09:11:28.030600Z

the reason we need this is that Chui also uses a macro to inspect the compiler state and find test vars. For that to work we have to be sure that this test-finding-macro only gets compiled after all the tests have been compiled, so conceptually you need this

(ns foo
  (:require alll...your...tests)
  (:require-macros [find-tests!])))

(find-tests!)

plexus 2020-08-21T09:12:23.032Z

but, we don't want to tell people to manually require their tests. That just leads to someone forgetting a test and it never being run. Shadow-cljs has provisions for this, if you use :browser-test or :node-test you can give it a test ns, and it will inject the necessary requires

miikka 2020-08-21T09:12:46.032800Z

i'm glad to see this problem tackled outside of shadow-cljs

borkdude 2020-08-21T09:13:07.033300Z

I've seen other solutions to create ns forms dynamically at read or compile time, but I think this one is more flexible and applicable to more than just kaocha.

miikka 2020-08-21T09:13:58.035100Z

(i mean, the shadow-cljs solution is good too, but not going to migrate all the non-shadow-cljs projects to shadow-cljs when i need to touch them :P)

plexus 2020-08-21T09:14:04.035300Z

I tried to propose adding similar functionality to the cljs compiler, but that wasn't warmly received. Instead David said "just use a macro", and I thought, "great", except that it turns out it doesn't work πŸ™‚

miikka 2020-08-21T09:14:20.035600Z

heh, yeah

plexus 2020-08-21T09:14:25.035800Z

so... (inc yak-stack)

borkdude 2020-08-21T09:14:53.036200Z

I don't think assuming shadow-cljs everywhere is great. It should be a choice

plexus 2020-08-21T09:15:49.037300Z

I know I know... but one of the reasons for kaocha-cljs2 is that we need some way to support people using shadow. Turns out that that is actually pretty easy because shadow has good testing provisions, but now it's a lot more work to support the rest again.

plexus 2020-08-21T09:16:44.038200Z

but yeah David agrees that this should work so I'm sure at some point it will work, and then we can support vanilla cljs as well as figwheel, lein-cljsbuild, etc.

plexus 2020-08-21T09:18:22.039300Z

the core of the issue of course is that shadow is really a different compiler from all the rest, so if people use shadow then all builds have to be done by shadow. If people use figwheel then we could still do a build with cljs.main as long as we have the same compiler opts

borkdude 2020-08-21T09:20:37.039900Z

This is kiiiind of the reason I'm still using cljs-test-runner, although you call it a POC, it works great for my purposes ;)

borkdude 2020-08-21T09:20:52.040100Z

But great to hear about the progress

miikka 2020-08-21T09:21:23.040800Z

I guess cljs-test-runner is kind of minimum viable test runner

borkdude 2020-08-21T09:21:50.041300Z

To be honest, I don't need much

plexus 2020-08-21T09:21:56.041600Z

I mean you could use kaocha-cljs, should work just as well. cljs-test-runner is really just a wrapper around doo, which does the compile-everything-to-a-blob thing, which I dislike because it lacks observability

borkdude 2020-08-21T09:22:04.041800Z

Same with CIDER: it has tons of features, but I probably only use 5% of them

borkdude 2020-08-21T09:22:43.042900Z

@plexus I've tried it but last time I tried it it didn't work with advanced compilation tests

plexus 2020-08-21T09:23:27.044200Z

true, it relies on a repl-env which implies :optimizations :none, but that's one of the use cases that kaocha-cljs2 will support

miikka 2020-08-21T09:24:26.045200Z

I've now worked a couple of months in this team where we maintain something like 20 services and the clojure/cljs ones just use lein test and Doo, and it works just fine... but if I ever need watching or Doo breaks, I'll introduce Kaocha

miikka 2020-08-21T09:27:00.045800Z

but well, it's always the Scala or the JS services that need the attention 😎

plexus 2020-08-21T10:43:23.046700Z

@tavistock you can try bin/proj install now if you want to install a local copy of kaocha-junit-xml

πŸ™ 1
plexus 2020-08-21T10:44:38.047500Z

➜ bin/proj
Usage: bin/proj [COMMAND] [COMMAND_ARGS...]

  release                            Release a new version to clojars
  pom                                Generate pom files
  install                            Build and install jar(s) locally
  gh_actions_changelog_output        Print the last stanza of the changelog in a format that GH actions understands
  help                               Show this help information
  inspect                            Show expanded opts and exit
  gen-readme                         Generate README based on a template and fill in project variables
  update-readme                      Update sections in README.md
I should release this as a proper tool at some point, but some lambdaisland-specific assumptions are baked in at this point

plexus 2020-08-21T10:45:50.048800Z

code is here http://github.com/lambdaisland/open-source/ if you're managing multiple open source projects and you want some unified setup, or if you have projects that consist of multiple sub-projects in one repo then this might be quite useful. I was surprised at the lack of good solutions for building/releasing libraries (and not just applications/uberjars) with deps.edn

plexus 2020-08-21T10:57:09.050100Z

A new kaocha-cloverage is out, it just bumps cloverage to 1.2.0, which again seems to contain a bunch of fixes and improvements. Thanks @cksharma122 for doing the upgrade!

πŸ‘ 1
plexus 2020-08-21T10:57:40.050500Z

πŸ‘‹:skin-tone-2: hi @bozhidar and @wxitb2017

πŸ‘‹ 1
Lucy Wang 2020-08-21T10:59:30.051400Z

Hi @plexus πŸ‘‹, i have been trying chui / kaocha-cljs2 , and it looks really promising! Thanks for the great work.

Lucy Wang 2020-08-21T11:01:10.052100Z

One thing that i miss most in shadow-cljs is the ability to only run a subset of tests, seems now I can do it with kaocha-cljs2!

plexus 2020-08-21T11:26:09.053400Z

hey that's awesome! kaocha-cljs2 is still pretty fresh but we're using it at Nextjournal and I'm actively working on it. If you find anything that bothers you let me know. Some user reports would be really helpful at this point.

πŸ’― 1
plexus 2020-08-21T11:27:32.053900Z

I'll update the docs soon to have some better instructions on how to set things up with or without shadow

πŸ‘ 1
svt 2020-08-21T11:56:04.054600Z

Is there a way to specify plugin for specific profile like only for :unit ?

plexus 2020-08-21T12:40:56.055500Z

No, plugins operate on a test run.

plexus 2020-08-22T09:20:03.075100Z

No, it's not technically possible. We have a few hooks that fire on the suite level, but most hooks fire once for the whole test run. E.g. what if you enable junit-xml for a single suite, and then run tests across multiple suites? That just doesn't make sense. Maybe explain what you're actually trying to accomplish and I can help figure out how best to do that.

svt 2020-08-22T09:24:27.075400Z

Thanks for the explanation :thumbsup: What I’m trying to achieve is not run coverage while running my integration tests. Reason being I have pre-commit hook that checks for coverage threshold. which can fail for integration tests. I want to check coverage threshold only for the unit tests.

plexus 2020-08-22T11:04:10.075600Z

I would look either into aero profiles, or set up a second tests.edn

svt 2020-08-22T14:54:31.075800Z

I’m not sure about setting up second tests.edn but aero profiles solves my problem πŸ™‚

svt 2020-08-22T15:14:54.076Z

Sorry for a stupid question, but the coverage report is not having colours (everything is coming in white text on terminal) as cloverage report gives. Is there any option that I need to enable?

plexus 2020-08-22T15:20:35.076200Z

No idea, I haven't looked at the cloverage stuff in a while...

2020-08-21T19:22:30.058100Z

Hey @plexus, I am trying to migrate to kaocha-cljs2 and don’t quite see how to plug it together with :node-test and shadow. I see there and node runner and a shadow-cljs runner but it looks like neither of those cover my specific use case

2020-08-21T19:37:25.059200Z

Okay looks like I am piecing it together a bit, I want to run the :browser-test config

2020-08-21T19:57:17.060100Z

Okay more piecing together. I can run some tests but those that depend on node.js libs don’t work because we are actually running in the browser

2020-08-21T19:57:43.060800Z

so I need to feed a node.js processes output to chui which should be running in its own process to render out the ui?

2020-08-21T19:57:59.061100Z

and this is connected via funnel?

2020-08-21T19:58:03.061400Z

something also these lines?