This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-01
Channels
- # announcements (11)
- # babashka (71)
- # beginners (34)
- # calva (25)
- # chlorine-clover (38)
- # cider (13)
- # clj-kondo (1)
- # cljsrn (2)
- # clojure (40)
- # clojure-australia (4)
- # clojure-europe (16)
- # clojure-france (3)
- # clojure-nl (4)
- # clojure-uk (16)
- # clojurescript (27)
- # conjure (2)
- # core-async (41)
- # core-logic (3)
- # cursive (1)
- # data-science (1)
- # datomic (16)
- # depstar (19)
- # emacs (7)
- # fulcro (33)
- # graalvm (4)
- # honeysql (20)
- # hugsql (4)
- # jobs (1)
- # juxt (4)
- # off-topic (48)
- # pathom (41)
- # reagent (9)
- # reitit (19)
- # remote-jobs (1)
- # shadow-cljs (20)
- # startup-in-a-month (2)
- # tools-deps (29)
- # vim (3)
- # xtdb (30)
Hello all, could someone give me a direction about testing clojurescript with reagent? I have setup luminus, figwheel, doo, karma and reagent and I have found a library called cljs-react-test, however I am getting a lot of errors with the sample in their github example and I would like to know what is the best approach to test components like a simple input text. Could someone, please, let me know what is the best approach to learn clojurescript using TDD/BDD?
hey! here is the test setup that I use for clojurescript: https://betweentwoparens.com/clojurescript-test-setup
You will notice that it’s a lean setup and this is on purpose. I try to avoid too many tools and wrappers in general and lean on the JS ecosystem
RE: testing reagent I use a combination of react test tools and https://testing-library.com/docs/react-testing-library/intro/
RE: learning TDD/BDD Can you elaborate of what you are looking to learn?
Hi @U6GNVEWQG thanks for replying to me. I have a looked in the link which you have sent. I am able to run lein test and also write normal test cases like: (deftest sample-test (is (= true true))). What I want to achieve is something like: I have a “home-page” component, a “menu” component and a “login”component. So there is a if inside my function if the user is logged in render the menu, otherwise a login page will be rendered.
Something as simple as :
(defn home-layout []
(if-let [user (session/get :identity)]
[home-user-layout]
[home-login-layout]
)
)
My components are simple as
(defn home-login-layout []
[:div
[h/render-header]
[:div.columns
[:div.column
[l/login-component]]]])
I am trying to learn by writing the test first and for instance: when the user is not logged in it should render the login page. I will check the links you have shared. thank you
I believe this will help mehttps://francisvitullo.medium.com/a-way-of-testing-views-in-clojurescript-apps-98aaf57c5c2a however I have just realized that I need to read about re-frame
Is there a way to build webworkers with :target :bundle
? I see that :webworker
is another value for the :target
key, but it seems like I need both for a :target :bundle
build. Or am I misunderstanding something?
Is there any prefered way to unfold an vector into another when building hiccup? I got it working with "into" but I wonder if there is a better way? "concat" didn't work
I don't think there's a better way than into
, assuming you mean something like (into [:div] children)
.
A bit relevant - note also that Reagent supports React fragments via :<>
.
@p-himik yes thats my usecase
ok i dont know what react fragments is, need to look it up
Ah, and often you can even use just [:div children]
. But my memory is a bit hazy here - I think only vectors are supported and seqs will whine about missing :key
.
okay, i was trying to make something like (menu {:prop xx :prop yy :items [(item {:prop...}]})
where i in menu need to inject the :items into the menu div
I am generating source maps in cljs using shadow-cljs compiler config:
:electron-main {:target :node-script
:main mutesync.inspect.electron.background.main/init
:devtools {:after-load mutesync.inspect.electron.background.main/done}
:compiler-options {:optimizations :simple
:source-map true
:source-map-include-sources-content true
:source-map-detail-level :all}
:output-to "shells/electron/js/background/main.js"}
generated map files: main.js
and main.js.map
I am trying to use this in sentry but they aren't working and as suggested I tried validating this sourcemap:
using this https://github.com/mozilla/source-map output: { source: null, line: null, column: null, name: null }
using this https://www.npmjs.com/package/sourcemap-validator output: error: "The map is not valid JSON"
shadow-cljs version: 2.11.15maybe this helps https://clojureverse.org/t/server-side-decoding-of-javascript-sourcemaps/1591/3?u=thheller
how can I validate these map in any browser then