polylith

J 2026-01-22T17:21:45.414309Z

Currently the poly test only Clojure code (not ClojureScript stuff). What is the workaround to test ClojureScript stuff?

J 2026-01-22T17:31:49.178259Z

For the moment, I add a test build inside the shadow-cljs.edn file for the project. The test can be launch with:

yarn workspace @poly/<my-cljs-project> test

seancorfield 2026-01-22T18:46:52.925309Z

I think part of the problem there is that there are far more cljs testing approaches than there are clj testing approaches. For the latter (Clojure), we have clojure.test compatible stuff (so the built-in Polylith test runner just uses clojure.test directly), and we have a Koacha test runner for Polylith (which supports clojure.test only), and my external test runner (which supports both clojure.test and LazyTest). The machinery is all pretty straightforward tho'. For my own projects that support ClojureScript, I use olical's cljs-test-runner. I could probably either integrate that into my external test runner as a wrapper. Are you using a JS runner on the compiled code?

J 2026-01-22T18:59:58.648329Z

For the moment, for the ClojureScript part I use cljs.test. The command yarn workspace @poly/<my-cljs-project> test just launch:

shadow-cljs compile test && node out/node-tests.js
But for the CI, I need to check if a project is cljs or not in order to launch the right test command.

seancorfield 2026-01-22T19:36:27.135819Z

The way poly test works is that it figures out which bricks (components, bases) depend on any changed code and which projects depend on those bricks, and then for each project it invokes the test runner with the list of nses. Your approach compiles and tests an entire project, I think? Incremental testing is one of the big wins with Polylith. Olical's cljs-test-runner works much more like Cognitect's test-runner, in that you tell it which source files/namespaces to run tests for, as I recall, so it's much closer to how Polylith works when testing.

seancorfield 2026-01-22T19:39:14.858159Z

I haven't explored what poly test tries to do with a mixed language project but I would expect it to pass the correct information to the test runner -- but the clojure.test runner would only look at .clj / .cljc (as Clojure). If poly test passes the correct information to the test runner, I could probably get the external test runner to use cljs-test-runner to run ClojureScript tests for .cljs / .cljc (as ClojureScript) files?

J 2026-01-22T19:44:53.047839Z

Since the poly test runs only .clj I need a way to test also the .cljs part separately. If poly tell me that project1 (clj) and project2 (cljs) need to be tested (with her deps), I will introduce a new step to detect cljs project and run the right command.

seancorfield 2026-01-22T19:56:06.344319Z

Right, I'm suggesting that I could extend my external test runner for Polylith to test both .clj and .cljs -- for the latter using cljs-test-runner I think. Which would make it integrated and only run tests for bricks that changed (or depended on changes). Your approach will test "all bricks" by virtue of the tests being run against the whole compiled project.

seancorfield 2026-01-22T19:58:10.497819Z

poly test only runs .clj tests for you because you're using the built-in Polylith test runner, and it only gathers .clj/`.cljc` -- whereas I'm using the external Polylith test runner and I can make it gather .cljs too. If you're interested in switching to Olical's cljs-test-runner, since that's how I would implement it.

seancorfield 2026-01-22T20:00:32.125819Z

Polylith's test runner is pluggable -- so you can configure it to use different runners.

👍 1
J 2026-01-22T20:03:20.168939Z

Oh it's interesting!

tengstrand 2026-02-07T12:44:18.550109Z

This sounds good @seancorfield!

J 2026-02-07T14:43:39.272069Z

That's it! we have our first cljs project inside our polylith repo at work. For the moment, this project is very simple: Only one base (pure cljs). Thanks to the discussion wirh @seancorfield, I have created a very very naive test runner only used for cljs project. This test runner run yarn workspace command that execute test for the current project. I know this is not ideal but for the moment (since the project has only one base) it's fine.

👍 1