Fork me on GitHub
#clojure-spec
<
2022-02-11
>
Quest20:02:29

How are you shimming Clojure.spec instrumentation in dev &amp; test, particularly with deps.edn? I was using lein :injections for this but find no equivalent mechanism in the deps.edn world. A test fixture solves test part, but I cannot find any version of this solution that doesn't require a (use-fixture ...) at the top of every test namespace. Does someone have an alternative solution? (Recommend an improved test runner?) Shimming in :dev seems to have two unclean approaches. 1) Make the editor inject on cider-connect [which varies for each editor] 2) Make the app itself support spec instrumentation as part of its official config-driven initialization -- & wait until point of invocation to (require) spec test.deps (as these aren't available in prod build)

Quest21:02:58

Closest solution for dev I've seen is https://underwhelm.net/blog/2019/12/19/tools-deps-injections/ , which works but is fragile

Quest21:02:56

From reading around, seems the solution of #2 is the "best approach," but it's a heavier pitch to my new team than I'd like https://github.com/jeaye/orchestra/pull/52

vemv15:02:15

as much as I'm a Lein fan / advanced user I really dislike :injections - they don't map 1:1 to an actual Clojure future so often people end up devising non-clean solutions that other folks are certainly solving in an idiomatic way.

vemv15:02:17

use-fixtures is fine and has the advantage that it will work with basically every test runner. You can always roll a tiny linter ensuring that each ns has this declaration. Otherwise using a bespoke test runner seems acceptable, there are a few e.g. eftest , circleci.test , kaocha , Polylith's.

Quest17:02:20

Hmm, I raised the use-fixtures PR but it changes 70 files. & you can't mix :use & :each fixtures in test. Making the linter check for the fixture is a good idea. If the team balks I'll mention some of the other test runners; it might be a hard sell, but would be cleaner in the end. Thanks for the thoughts & advice!

🍻 1