@itai The thing to realize is that ddiff/pretty-print does actually printing, whereas you seem to be expecting that it returns a string. That's a bit more involved, something like this:
(ns repl-sessions.poke
(:require
[lambdaisland.deep-diff2.puget.printer :as ddiff-printer]
[lambdaisland.deep-diff2.printer-impl :as ddiff-printer-impl]
[lambdaisland.deep-diff2 :as ddiff]
[clojure.test :refer :all]))
(defn ddiff->str [expected actual]
(ddiff-printer/render-str
(ddiff/printer)
(ddiff/minimize (ddiff/diff expected actual))))
now you can do
(let [expected {:a 1 :b 2 :c 3}
actual {:a 1 :b 2 :c 4}]
(is (submap? expected actual)
(ddiff->str expected actual)))
or (this is getting close to dark arts), you can override how clojure.test handles the 'submap? predicate
(defmethod clojure.test/assert-expr 'submap? [msg form]
(let [[_ expected actual] form]
`(let [exp# ~expected
act# ~actual]
(if (submap? exp# act#)
(do-report {:type :pass, :message ~msg,
:expected '~form, :actual (cons 'submap? exp# act#)})
(do-report {:type :fail, :message (ddiff->str exp# act#)
:expected '~form, :actual (list '~'not (list '~'submap? exp# act#))})))))Now if you use (is (submap? ...)) it'll automatically print the diff
(let [expected {:a 1 :b 2 :c 3}
actual {:a 1 :b 2 :c 4}]
(is (submap? expected actual)))
but like @lee said matcher-combinators is the way to go. You should be able to add :diff-style :minimal to your kaocha config in order to reduce the diff size.