etaoin

borkdude 2020-06-27T09:57:40.065600Z

@rickmoynihan I actually am using this now myself:

(defmethod clojure.test/assert-expr 'working? [msg form]
  (let [body (next form)]
    `(do ~@body
         (clojure.test/do-report {:type :pass, :message ~msg,
                                  :expected :success, :actual :success}))))

(is (working? (+ 1 2 3))) ;; works
(is (working? (throw (ex-info "" {})))) ;; doesn't work

2020-06-27T11:45:44.070800Z

Ahh I meant to pop back yesterday and say thanks for the idea @borkdude… this is what I wrote and started using:

(defmethod clojure.test/assert-expr 'effected? [msg form]
  ;; Intended to allow etaoin wait forms to become assertions that
  ;; contribute to the test count etc...
  ;;
  ;; Used like (is (effected? (et/wait-visible driver {:css ",,,"})))
  (let [body (rest form)]
    `(try
       ~@body
       (clojure.test/do-report {:type :pass, :message ~msg,
                                :expected '(nil? ~@body) :actual nil})
       (catch clojure.lang.ExceptionInfo e#
         (clojure.test/do-report {:type :fail, :message ~msg,
                                  :expected '(nil? ~@body) :actual e#})))))
Also this way will count and report the raised exceptions as failures rather than errors — though admittedly it’s not ideal and the stack traces could possibly be summarised. I thought effected? might be a better name for the etaoin use case, as typically you’ll be waiting on an effect to happen on the website… Open to better names for it, I did think happens? but (is (happens? ,,,)) is kinda gross, some colleagues suggested transpired? and materialised? too.

2020-06-27T11:49:25.071400Z

I do wonder if something like this should be mentioned in the etaoin docs