chui icon indicating copy to clipboard operation
chui copied to clipboard

Patch for empty `re-find` call in Safari?

Open rgm opened this issue 3 years ago • 1 comments

For whatever reason, my cljs tests that use (is (match? ,,,)) from nubank/matcher-combinators are blowing up in Safari 15.6.1 with the error TypeError: re-find must match against a string.

image

It looks like the issue is an unexpected nil at https://github.com/lambdaisland/chui/blob/main/modules/chui-core/src/lambdaisland/chui/runner.cljs#L93-L94. My quick logging check on the erroring tests was giving me a value for line-col of "@".

It seems to me this is imperfect and likely to be revisited when conditions change in cljs.test.

Can I propose the following patch? If so, I'll make up a PR. Test line/col reporting remains broken (as it is now). But least it will get us to actionable test failures on Safari:

diff --git a/modules/chui-core/src/lambdaisland/chui/runner.cljs b/modules/chui-core/src/lambdaisland/chui/runner.cljs
index c3d9575..af1c89f 100644
--- a/modules/chui-core/src/lambdaisland/chui/runner.cljs
+++ b/modules/chui-core/src/lambdaisland/chui/runner.cljs
@@ -90,8 +90,8 @@
         (let [line-col (drop (- (count frame) 2) frame)
               file     (str/join ":" (take (- (count frame) 2) frame))]
           {:file   file
-           :line   (js/parseInt (re-find #"\d+" (first line-col)) 10)
-           :column (js/parseInt (re-find #"\d+" (second line-col)) 10)})))))
+           :line   (js/parseInt (re-find #"\d+" (str (first line-col))) 10)
+           :column (js/parseInt (re-find #"\d+" (str (second line-col))) 10)})))))
 
 (defmulti report :type)
 (defmethod report :default [_])

rgm avatar Aug 24 '22 21:08 rgm

Seems like a reasonable fix, a PR would be great! Thanks!

plexus avatar Aug 25 '22 09:08 plexus

PR is merged, so this can be closed.

plexus avatar Jan 25 '23 09:01 plexus