How to unit testing Rum components?

Hi everyone,

recently I have started to learn/use Rum to develop a mock interface [1] for an upcoming side project; at some point I got stuck while working on a simple component [2] so I was wandering if there is a common approach to (unit) test single components in an isolated way; the problem for me was that the error in that component’s code was “crashing” the whole app and the error reported in the browser’s console was not helping too much.

Thanks in advance for your help!

[1] I know there are lots of tools to create mockups but as a solo developer I decided that it is a better use of my time to create something that later can be attached to a backed without restarting from scratch again.

[2] here is the component if someone is curious

(rum/defc select-options [{:keys [name options selected]}]
  (into [:select {:name name}]
           (fn [{:keys [label value]}]  ;; <-- here I have previously forgotten to destructure the map
             [:option {:value value :selected (= selected value)} label])

a call to that component

(select-options {:name "name-attribute-of-the-select"
                 :options [{:label "Option 1" :value 1}
                           {:label "Option 2" :value 2}
                           {:label "Option 3" :value 3}]
                 :selected 2})
1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.