This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-05-31
Channels
- # announcements (6)
- # babashka (40)
- # beginners (6)
- # calva (1)
- # cider (1)
- # clerk (43)
- # clj-kondo (3)
- # clojure (93)
- # clojure-denver (8)
- # clojure-europe (52)
- # clojure-norway (20)
- # clojure-sweden (7)
- # community-development (5)
- # datascript (15)
- # datomic (30)
- # emacs (24)
- # events (15)
- # fulcro (23)
- # graalvm (12)
- # gratitude (1)
- # helix (4)
- # honeysql (4)
- # hoplon (39)
- # hyperfiddle (7)
- # introduce-yourself (1)
- # jobs (1)
- # jobs-discuss (26)
- # lambdaisland (3)
- # lsp (6)
- # matcher-combinators (2)
- # matrix (5)
- # meander (39)
- # nrepl (4)
- # nyc (1)
- # off-topic (5)
- # portal (73)
- # practicalli (1)
- # re-frame (2)
- # reitit (22)
- # releases (1)
- # remote-jobs (4)
- # shadow-cljs (5)
- # sql (17)
- # testing (1)
- # tools-deps (15)
Hello, I'm trying to use deep-diff2
to print errors to my assertions.
I'm using a submap
function to assert that "expected" contains all of "actual".
When the test fail though, I get a huge unreadable message.
I have tried using diff with pretty-print, but it seems to add a lot of breaklines and ends up unreadable as well.
(defn submap?
"Is m1 a subset of m2?"
[m1 m2]
(cond
(and (map? m1) (map? m2)) (every? (fn [[k v]] (and (contains? m2 k)
(submap? v (get m2 k))))
m1)
(and (vector? m1) (vector? m2)) (and (= (count m1) (count m2))
(every? identity (mapv submap? m1 m2)))
:else (= m1 m2)))
(let [actual (build-layout input [])]
(is (submap? expected actual)
(-> (ddiff/diff expected actual)
ddiff/minimize
ddiff/pretty-print)))
What am I doing wrong and how can I fix it?I love deep-diff2, but for this kind of test I really like https://github.com/nubank/matcher-combinators
🙌 2