kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
2021-01-17T19:28:55.005300Z

Hey all, I am trying to use kaocha with cljs-bean and it seems like deep-diff doesn't like beans:

Actual:
  -#function (meta,obj,prop__GT_key,key__GT_prop,transform,recursive_QMARK_,__arr,__cnt,__hash){
this.meta = meta;
this.obj = obj;
this.prop__GT_key = prop__GT_key;
this.key__GT_prop = key__GT_prop;
this.transform = transform;
this.recursive_QMARK_ = recursive_QMARK_;
this.__arr = __arr;
this.__cnt = __cnt;
this.__hash = __hash;
this.cljs$lang$protocol_mask$partition0$ = 2164131599;
this.cljs$lang$protocol_mask$partition1$ = 139268;
} "{:$metadata {:httpStatusCode 200, :httpHeaders {:date \"Sun, 17 Jan 2021 19:00:06 GMT\", :content-type \"applicat
ion/x-amz-json-1.0\", :x-amz-crc32 \"2745614147\", :x-amzn-requestid \"4760a996-a00c-4623-af7e-7bb7b94c611e\", :cont
ent-length \"2\", :server \"Jetty(9.4.18.v20190429)\"}, :requestId \"4760a996-a00c-4623-af7e-7bb7b94c611e\", :attemp
ts 1, :totalRetryDelay 0}, :Attributes nil, :ConsumedCapacity nil, :ItemCollectionMetrics nil}"
  +{}
Is there a clean way for me to add diffing of bean's?

2021-01-17T20:49:42.005900Z

I figured it might be enough do something like:

(ns deep-diff-bean
  (:require [cljs-bean.core :as be]
            [clojure.data :as data]
            [lambdaisland.deep-diff2 :as dd2]))

(defn diff-bean
  [exp act]
  (data/diff-associative
   (-> exp
       be/->js
       (js->clj :keywordize-keys true))
   (-> act
       be/->js
       (js->clj :keywordize-keys true))))

(extend-protocol lambdaisland.deep-diff2.diff-impl/Diff
 cljs-bean.core/Bean
  (-diff-similar [exp act]
    (lambdaisland.deep-diff2.diff-impl/diff-map exp act)))

(extend-protocol clojure.data/Diff
  cljs-bean.core/Bean
  (diff-similar [exp act]
    (diff-bean exp act)))

(comment
 (data/diff {:x 1} {:x 2})
 (dd2/pretty-print (data/diff (be/bean {:x 1}) (be/bean {:x 2})))

 (dd2/diff {:x 1} {:x 2})
 (dd2/pretty-print (dd2/diff (be/bean #js{:x 1}) (be/bean #js{:x 2}))))
which appears to work at the repl if I call the diffs in the comment block but when running kaocha-cljs2 against a node.js target it still pukes up. I have the protocol extension in my node-runner but it seems that isn't enough

2021-01-17T20:50:20.006400Z

but doesn't seem to work via kaocha-cljs2