👋 What's the story for REPL usage w/ Cherry? Can I spin up an nREPL? Thinking about how I'd go about developing Playwright tests via REPL in Cherry :)
@rahx1t This isn't yet there. It's the first thing I'm going to work on after further extracting the common code into compiler-common. Squint does have a console REPL at the moment
Is there a p/do or p/let-like macro floating around for use with Cherry? Seeing what's out there before writing my own 🙂
@rahx1t there isn't currently and there probably won't be one since async/await works in cherry :)
I do love await but feel like there's still value in abstracting that away with a macro. Lazy and trying to type as little as possible 🙂 My code atm is await everywhere lol
haha I see :)
(pw-test "auth via sign-in"
(w/allPagesWrapper
^:async
(fn [^:js {:keys [page context]}]
(js/await (.goto page index))
(js/await (wait-for-client-side-rendered page))
(js/await (.click (.locator page "data-testid=sign-in >> visible=true")))
(js/await
(js/Promise.all [(.waitForNavigation page #js {:url "**/groups/new"})
(let [[new-page] (js/await
(js/Promise.all [(.waitForEvent context "page")
(.click (.locator page "data-testid=sign-in-with-google-button"))]))]
(js/await (.waitForLoadState new-page))
(js/await (.click (.locator new-page "'Add new account'")))
(js/await (.click (.locator new-page "'Auto-generate user information'")))
(js/await (.click (.locator new-page "#sign-in"))))]))
(js/await (wait-for-user-loaded page)))))I haven't audited this to ensure there aren't any unnecessary awaits, but you catch my drift
you can currently write macros if you have them in file under . or src , e.g. src/my_macros.cljc and then require it with (:require-macros [my-macros :refer [foo]])
Great, I'll give that a try
there is one such example in the nextjournal cherry playwright one
I recall, yes - with assert right?
that one yes
the macros are interpreted with SCI during compilation
and then the expansion is compiled to JS
Nothing fancy but I'm appreciating the quality of life improvement 🙂 The js/await makes async macros soooo much easier to write thanks3
(defmacro do! [& exprs]
(let [[first-expr & rest-exprs] exprs]
(reduce
(fn [acc# next#]
`(.then ~acc# (fn [_#] ~next#)))
`(js/Promise. (fn [resolve#] (resolve# ~first-expr)))
rest-exprs)))
(defmacro do! [& exprs]
`(do
~@(map (fn [expr#] `(js/await ~expr#)) exprs)))await-> coming? 🙂