thheller / shadow-cljs

ClojureScript compilation made easy
https://github.com/thheller/shadow-cljs
Eclipse Public License 1.0
2.27k stars 180 forks source link

Feature request: focus on tests #898

Open svantevonerichsen6906 opened 3 years ago

svantevonerichsen6906 commented 3 years ago

Would it be possible for the test runners to allow focusing on single tests?

What I have in mind is similar to what lein-test-refresh does: https://github.com/jakemcc/lein-test-refresh#built-in-test-narrowing-test-selector. You mark one or more tests with a metadata flag, and then only those get executed.

I think that it should be possible to build this into https://github.com/thheller/shadow-cljs/blob/8169e663c0338ab01b31726b0cfcd7005563c581/src/main/shadow/test/env.clj, but I think it should be activated by a parameter so that you don't accidentally forget a focus mark and disable most tests of an automatic pipeline.

thheller commented 3 years ago

A basic version is already supported for :node-test, eg. node out/test.js --test=some.ns/foo-test. See https://github.com/thheller/shadow-cljs/blob/8169e663c0338ab01b31726b0cfcd7005563c581/src/main/shadow/test/node.cljs

That could be smarter of course. PR welcome.

logseq-cldwalker commented 2 years ago

@thheller I built this node test runner at work which supports the same test selection options as https://github.com/cognitect-labs/test-runner#invoke-with-clojure--m-clojuremain. Would you like a PR to shadow.test.node to incorporate those options?

thheller commented 2 years ago

Can you write this as a standalone ns that doesn't use shadow.test.node? Just copy whatever you need from it over and adjust. I'd be open to an option that keeps the existing --test just so that people using that can continue to do so.

logseq-cldwalker commented 2 years ago

Can you write this as a standalone ns that doesn't use shadow.test.node? Just copy whatever you need from it over and adjust

Great that you're interested! Sure. I'd just name it shadow.test.node-test-runner unless you have another preferred name

I'd be open to an option that keeps the existing --test just so that people using that can continue to do so

The -v or --var already provides the functionality. We could alias it to --test if you'd like

Is there a place I could document usage of the options?

We're just starting to use this at work. My plan is to use the runner a week or two before creating a shadow-cljs PR so I can squash any bugs quickly