This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-05-11
Channels
- # announcements (4)
- # babashka (4)
- # beginners (164)
- # calva (47)
- # cider (1)
- # cljs-dev (29)
- # cljsrn (3)
- # clojure (137)
- # clojure-europe (23)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (44)
- # clojurescript (35)
- # component (8)
- # conjure (119)
- # cursive (32)
- # datomic (12)
- # emacs (31)
- # figwheel-main (36)
- # graalvm (10)
- # jobs (2)
- # kaocha (1)
- # lein-figwheel (3)
- # meander (15)
- # mount (3)
- # off-topic (9)
- # pathom (8)
- # quil (4)
- # re-frame (13)
- # reagent (15)
- # remote-jobs (10)
- # shadow-cljs (128)
- # slack-help (2)
- # spacemacs (8)
- # test-check (6)
- # xtdb (6)
anyone tried the new `functional-compiler` of reagent? how would I know that Reagent actually creating function components and not Class components? I mean how can I see the React code that comes out ?
Also, using the new functional-compiler
how would you use third party libraries? it's all the same as it was?
I'm trying to use react-testing-library with shadow-cljs and am wondering if I should target the :browser-test
or :node-test
for it. I mean in the React world, jest is obviously not targeting the browser ...
It should be :karma
. Here is a build config that I recently used to solve the same problem.
:karma-test
{:target :karma
:output-to "out/karma/test.js"
:output-dir "out/karma"
:source-path "karma"
:compiler-options {:infer-externs :auto}
:ns-regexp "-test$"}}}
Please go through this - https://shadow-cljs.github.io/docs/UsersGuide.html#target-karma
Hmm. I'm under the impression that using Karma actually also involves launching a browser to run the tests. If possible, I would like to avoid this.
Nope, you can run in headless mode
I'm not sure how react-testing-library works but if its meant to run in node then :node-test should be fine
react-testing-library does expect to use the DOM; so you’ll want to run it either in a browser context (using :browser-test
for local dev and :karma
for CI) or in :node-test
and provide a DOM polyfill like jsdom: https://github.com/jsdom/jsdom
Well, when I try to run it in a browser context, a basic test I ran apparently gets confused with the generated result page, so I was mostly thinking about using it with jsdom. I'll give karma a shot first, though and see if that just works.
And of course it turns out that not react-testing-library was confused but my test and it works as a browser-test just fine.
I'm sorry if this is such a newbie question, but if I wanted to reagent-ify a google closure component such as DatePicker, how would I do so? I've tried copying the technique in https://github.com/reagent-project/reagent/blob/master/doc/InteropWithReact.md but I get an error react_devtools_backend.js:6 error when calling lifecycle function pc-ward.core/mount-root TypeError: this.getBaseCssClass is not a function at goog.ui.DatePicker (datepicker.js:105) I probably need to learn react and javascript before trying to convert JS examples into cljs! All tips appreciated thank you.
@mark354 a google closure component has nothing to do with react, so you’re going to struggle a lot trying to use anything in that document with https://google.github.io/closure-library/api/goog.ui.DatePicker.html
Ah I see. Thank you. I assumed the reagent macro did all of the js getElementById and render for an arbitrary component. So essentially I have to create a reagent “form 3” type and run getElementById and render from there into the DOM fragment? Thanks I’ll give this a try.