Fork me on GitHub
#clojurescript
<
2023-05-16
>
niwinz14:05:37

There is a way to run a single test in cljs.test ? I expecting something like this on jest: https://jestjs.io/docs/setup-teardown#general-advice test.only(() => {});

seancorfield14:05:05

Perhaps http://cljs.github.io/api/cljs.test/test-vars which lets you explicitly run one or more test?

niwinz14:05:35

but how I can use that? I'm not using REPL, I'm just running shadow-cljs watch process with autorun

seancorfield15:05:01

Ah, I always use a REPL and almost never have a watch process running...

niwinz15:05:38

I mean I find that all api is REPL orientend and it is ok, but this is not the only way to it. I'm not always connected to REPL (in clojurescript)

niwinz15:05:37

this is also interesting to have this for run a single test in CI, where you obviously don't hava a REPL connection

niwinz15:05:01

the problem here I guess is that the api is 100% oriented to be run on REPL session (which is ok but limiting because there are also other approaches for do it without having the REPL setup on clojurescript)

seancorfield15:05:21

I don't understand why you'd want CI to run just a single test? That seems contrary to the whole point of CI.

niwinz15:05:34

This is not the point, the point is I want a shell running watch test. And just execute the test on each modification, without the need to eval on the REPL an expr for running the test

niwinz15:05:57

and right now I don't find a way to do it

niwinz15:05:44

Right now the solution to this problem is: go to all other ns and comment the tests while you develop X feature. And no... the REPL is not an option here, because I don't want constantly go to a buffer on emacs for eval an expr for running a test, I want the single test running on each save, without the need to switch my context to the REPL.

niwinz15:05:07

My workflow is a bit different but it does not makes it worse or better than others, just that the cljs.test right now is oriented to REPL workflow that In my concrete case I don't use, so I'm limited to the rudimentary solution to comment tests hehe

niwinz15:05:33

and would be awesome have helpers for other kind of workflows on cljs.test 😛

seancorfield15:05:59

Depending on your test runner, maybe you could use metadata tags on your tests and configure the runner to run only tagged tests?

seancorfield15:05:00

(deftest ^:only some-test ...) and then tell the runner to only run tests with the :only metadata? I don't know if that's possible in ClojureScript, but the Clojure test runners all support that I believe.

niwinz15:05:44

yep, that is something I thinking, yes, I asked if there are something already done before going to implement it.

niwinz15:05:26

yep on closure is more easy to implement, but my main target is on clojurescript rightnow

niwinz15:05:36

in any case, thanks for your time