Skip to content

A ClojureScript library for efficient testing of Reagent and Re-frame applications

Notifications You must be signed in to change notification settings

HealthSamurai/retest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Retest

Library for testing Reagent based applications

Features

  • 🖨️ Extracting component data
  • 👆 Clicking on an element
  • 📝 Input element filling
  • 👀 Component rendering

Installation

com.health-samurai/retest {:git/url "https://github.com/HealthSamurai/retest.git"
                           :sha "f83591af5d0f75dcdb5731dcdc59d5519b4d6c41"}

Usage

render

(defn form-1
  [v]
  [:div v])

(defn form-2 [_]
  (fn [v]
    [form-1 v]))

(retest.core/render [form-2 1])

;; => [:div 1]

datafy

(defn component 
  []
  [:div {:data-object :a}
    [:div {:data-key :b} "1"]
    [:div {:data-array :c}
     (for [i [1 2 3]]
       [:div {:data-key :d} i])]])

(retest.core/datafy component)

;; =>
;; {:a {:b "1"
;;      :c [{:d "1"}
;;          {:d "2"}
;;          {:d "3"}]}}

click

(defn component
  []
  [:form [:button {:id ::foo :on-click (fn [_] (prn "clicked"))}]])

(retest.core/click component ::foo)

;; => "clicked"

fill

(defn component
  []
  [:form
   [:input {:id ::foo
            :on-change (fn [event]
                         (prn #?(:clj  (-> @event :target :value)
                                 :cljs (.. event -target -value))))}]])

(retest.core/fill component ::foo "value")

;; => "value"

References

About

A ClojureScript library for efficient testing of Reagent and Re-frame applications

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published