This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-07-21
Channels
- # admin-announcements (4)
- # beginners (41)
- # boot (46)
- # cider (8)
- # clojure (132)
- # clojure-austin (15)
- # clojure-belgium (3)
- # clojure-greece (3)
- # clojure-hk (1)
- # clojure-mexico (4)
- # clojure-quebec (5)
- # clojure-russia (46)
- # clojure-spec (225)
- # clojure-taiwan (1)
- # clojure-uk (17)
- # clojurescript (46)
- # clojurewerkz (1)
- # core-async (28)
- # cursive (9)
- # datascript (3)
- # datomic (5)
- # defnpodcast (42)
- # devcards (60)
- # emacs (27)
- # hoplon (7)
- # lein-figwheel (5)
- # leiningen (12)
- # mount (8)
- # om (13)
- # play-clj (2)
- # reagent (47)
- # rethinkdb (5)
- # ring-swagger (7)
- # spacemacs (9)
- # specter (12)
- # testing (1)
- # untangled (1)
- # vim (11)
- # yada (31)
anyone?
@nnbosko: see if this works:
(defn filter-dd [results]
(r/create-class
{:component-did-mount (fn [this] (.dropdown ($ (r/dom-node this)) #js {:onChange (fn [v,t,c] #_(println v t c) (get-entries-by-tag results v))}))
:reagent-render
(fn []
[:div {:class "ui fluid selection dropdown" :id "tag-dd"}
[:input {:name "tag" :type "hidden"}]
[:div {:class "default text"} "Filter by Tags"]
[:i {:class "dropdown icon"}]
[:div {:class "menu"}
(for [i log-events]
^{:key (:tag i)}
[:div {:class "item" :data-value (:tag i)} (str (:tag i) " - " (:description i))])]])}))
same result
or error, rather
core.cljs:120 Uncaught TypeError: jayq.core.$.call(...).dropdown is not a function
Alright, I'll ask in cljs then
Thanks!
Same error, though at least it says $(...).dropdown is not a function now
It's kinda wierd cause I haven't had this issue in previous projects
@nnbosko: I think I got it. I tried the spirit of your code with a minimal example, and it worked for me. However, when i didnt include the semantic ui javascript, i get the error that you see. If you are using cljsjs, dont forget to include this in your namespace requires [cljsjs.semantic-ui]
I fixed the mistake; turns out I was loading app.js before semantic.js, it's always the little things 😛
wondering what tools people are using currently for unit testing / integration testing using cljs and a react wrapper like om or reagent?
@mattsfrey: i basically use this setup, doo and react test utils for unit testing. https://github.com/reagent-project/reagent-cookbook/blob/master/recipes/test-example-with-ReactTestUtils/README.md
I would recommend not testing the UI. Any logic should be pulled out of your react/reagent components and unit tested in isolation
@bostonaholic: I've found it pretty useful to test certain areas of the UI in the past, particularly in places where the UI is more complicated than the logic behind it. Before devcards it wasn't worth the overhead for my projects, but I now use devcards to both design and allow testing and verification for the parts of the UI that it makes sense for.
I understand some find it useful. I haven’t found testing the UI very useful and more of a hindrance in my experience. When thinking about a UI in terms of “data-driven” if you’re testing anything other than the data, you might have a bad time.
tests need to then change when a UI tweak is made and not a behavioral change, which is what I prefer to focus my tests on
to me, testing the UI (react/reagent) is similar to testing ring or another lib on the server. Tests should be blind to underlying implementations
interesting, I had been leaning in this direction myself overall as we use inline styles and everything in the app is literally a function that returns hiccup and could be tested as such etc
I find little value in testing hiccup and/or css styles
@shaun-mahood: any particular areas in specific you like to test?
hiccup and any UI specific generation should be “dumb"
@bostonaholic: do you not find it useful to do integration tests such as going through login flows and such? Part of me leans towards at least having some tests being done by a headless browser to verify some of the ui flows work properly
if I do, it should not be relying on reagent
but I rarely do
UI tests are slow, cumbersome, and break easily
there often times are faster tests that can be written which describes the behavior of your “flow” which do not require the UI
@mattsfrey: Here's what I've done for the places where it's held the most value for me. I design the component in devcards (as data-driven as possible), then set up a number of cards to test the areas I'm interested in validating or testing. Usually I will have a couple to test the basic functionality and expected data, then I will add more individual cards for edge cases that I expect may have some issues or add cards for particular issues I run into during development or that users run into later on. I will often test how the component fits into certain HTML or CSS structures (things like floating multiple components, fixed-width divs, etc.) depending on the expected use, as well as particular widths to test for things like phones and tablets. I will then use the test page to verify that everything still looks as expected as I'm making changes that may affect things (particularly CSS changes) and to rule out or narrow down issues when I run into other problems with the overall program.
I will definitely try out devcards and see if I like it, heard a lot of people recommend it
I’ve not used devcards so I’m unfamiliar with testing it
but there would be ways to test what you described without the use of UI in your tests
for instance, width can be calculated and passed to the component before render, test that piece instead of the component’s width
@mattsfrey: I would recommend it, it's changed the way I develop web apps and I would hate to have to live without it. It changed the way I look at UI development. There is a great intro video at https://www.youtube.com/watch?v=G7Z_g2fnEDg
I am impressed by devcards and would like to try it out, just haven’t taken the time
@bostonaholic: I think it may just come down to preferences and habits, as well as team structure and application size and scale. Devcards has hit the sweet spot for what I want out of UI testing and may not work for what you are looking for in terms of your testing requirements, but I would still use it for design and development even if I weren't using it for any types of testing.
I completely agree
and I can’t yet say if using devcards works for me or not, since I’ve not taken the time to try it out