chui
chui copied to clipboard
Patch for empty `re-find` call in Safari?
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.
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 [_])
Seems like a reasonable fix, a PR would be great! Thanks!
PR is merged, so this can be closed.