Fork me on GitHub
#clojure
<
2022-02-25
>
Dongwook Kim04:02:48

Hello all, Is there anyone who experience Reader class not found error using carmine? I’m using 3.1.0 version

jumar04:02:04

Perhaps a conflict in transitive dependencies versions?

Dongwook Kim04:02:28

It might be... but problem is I don’t know which lib is causing conflict :thinking_face:

Dongwook Kim04:02:09

I’ve found someone who had same issue and he solved excluding clojurescript from his edn but I don’t have it

Dongwook Kim04:02:02

um…. I’ve just add encore which is version 3.21, and It solved 😅 thanks for your comment! @U06BE1L6T

Alex Miller (Clojure team)17:02:16

it's Friday and if you're looking to slack off for a few minutes, why not answer the 2022 Clojure survey? takes 5-10 min. https://www.surveymonkey.com/r/clojure2022

5
hiredman18:02:36

static method

orestis18:02:40

The guidance from java-land is to do import _static_ com.microsoft.playwright.assertions.PlaywrightAssertions.assertThat; and then just use assertThat as a top level thing.

ghadi18:02:48

(TheInterface/method ...)

hiredman18:02:58

yeah, same as any other static method

orestis18:02:09

The obvious (com.microsoft.playwright.assertions.PlaywrightAssertions/assertThat) fails with ClassNotFound

hiredman18:02:52

and what does com.microsoft.playwright.assertions.PlaywrightAssertions in the repl do?

orestis18:02:04

IT's not a class, it's an interface.

hiredman18:02:32

your repl doesn't have that type available to it

orestis18:02:44

An interface with static methods that include implementations.

hiredman18:02:06

an interface is a kind of class basically, when it comes to the jvm

R.A. Porter18:02:28

java.lang.Appendable is an example of an interface. What happens when you type that into the REPL?

borkdude18:02:41

@orestis Have you considered using playwright from CLJS on Node.js?

R.A. Porter18:02:42

(answer: not CNFE)

hiredman18:02:04

so interfaces are looked up via class*loaders and result in *class not found exceptions

orestis18:02:33

@borkdude yes but I'd prefer to keep these tests on the JVM if possible

borkdude18:02:38

Sure. I'm asking because writing tests with #nbb + playwright is pretty smooth, I've already done it in two projecs ;)

orestis18:02:08

Smoother than plain Clojure? 🙂

orestis18:02:43

In our case we have to spin up server, setup fixtures etc etc so since this is already in the JVM it probably makes sense to do the testing in-process

borkdude19:02:06

yeah, makes sense

borkdude19:02:19

I don't have experience with Playwright on Java I must say

orestis19:02:30

(ns nosco.test.browser-helpers
  (:import [com.microsoft.playwright
            Playwright Browser Page Locator
            BrowserType$LaunchOptions]
           [com.microsoft.playwright.assertions
            PlaywrightAssertions]))


(defn launch-options [{:keys [headless slomo]}]
  (let [options (BrowserType$LaunchOptions.)]
    (.setHeadless options headless)
    (when slomo
      (.setSlowMo options slomo))
    options))


(defn launch-browser [pw launch-options]
  (let [b (.. pw chromium (launch launch-options))]
    b))

(def PW (Playwright/create))

(def B (launch-browser PW (launch-options {:headless false
                                           :slomo 50})))

(def P (.newPage B))
(.navigate P "")

(->
 (.locator P "text=powered")
 (PlaywrightAssertions/assertThat)
 (.containsText "powered by"))

orestis19:02:02

That's all there is to it so far. Jar is on maven, API docs seem decent. No async stuff.

orestis19:02:34

It downloads and caches the browser runtimes on first attempt to create a PW instance.

borkdude19:02:59

That's what it also does on Node

orestis19:02:55

For me the value is mostly on no async, plus the whole idea of setting up fixtures and tearing them down

borkdude19:02:43

The setting up and tearing down is supported in nbb (cljs.test) too. The async stuff is mitigated by promesa which has macros that make it almost seem like you're writing sync code.

orestis19:02:42

Sorry, I meant setting up fixtures of our actual app, not the PW itself.

orestis19:02:21

I'll take this as a vote of confidence on the general project though. Seems very polished.

borkdude19:02:47

oh, you mean, like, fixtures as in mocks?

flowthing19:02:47

FWIW, I've used one Node.js Playwright in one project and JVM Playwright in another and I'd pick JVM Playwright all day, every day. :)

flowthing19:02:13

No experience with nbb, though.

borkdude19:02:20

I didn't even know it existed for the JVM until today ;)

flowthing19:02:55

Yeah, I didn't either when I used the Node.js version for the first project. 🙂

orestis19:02:27

Fixtures as in inserting data in a database and then testing that the frontend comes up with the correct answer 🙂

orestis19:02:50

I searched for Puppeteer java and instead somebody suggested playwright 😉

borkdude19:02:21

Playwright is the spiritual successor of Puppeteer, same team, migrated to a different company

hiredman18:02:37

you'll need to look at how your repl was launched and see if that class/type/interface is available to it

hanDerPeder18:02:33

is there a known implementation of a function that, given a spec and a map, walks the map and only keeps the keys mentioned in the spec recursively?

orestis18:02:59

@hiredman thanks. I can't see why it shouldn't be available, everything else is. I guess I can open the jar and poke around.

hiredman18:02:44

1. restart your repl 2. make sure the version you are looking at on github is the same as the verion you are using

hiredman18:02:14

my guess is the version in maven is older and doesn't have the type

orestis18:02:08

indeed, it's not in the JAR, and indeed, i'm using an older version of the jar 😳

orestis18:02:35

Thanks for the guidance everyone

Noah Bogart19:02:42

I just wrote a function that returns a "conversational string" for the type of a given input, so 1 returns "string" and {:a "hello"} returns "map". i feel like i'm reinventing the wheel but i don't see anything in the core library. am i missing something obvious?

Alex Miller (Clojure team)19:02:33

type or class are in that ballpark, but don't know of anything that makes "simpler" names like that

dpsutton19:02:21

I’d be surprised if 1 returned "string" 🙂

😂 1
borkdude19:02:39

I have something like that in clj-kondo... but probably not re-usable outside of that context.

Noah Bogart19:02:34

whoops yes, i mean 1 returns "number"

Noah Bogart19:02:48

cool, as long as i've not missed something obvious

dpsutton19:02:07

what do you return for (deftype Foo [a]) ? Or for com.microsoft.playwright.assertions.PlaywrightAssertions? I guess you just have a map of common versions, check ancestors against it and then return the className otherwise?

Noah Bogart19:02:01

Yes, I'm checking the basic data types (symbol, keyword, string, number, map, set, seq, and vector) and then defaulting to (type input).