HealthSamurai / retest

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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


Languages

Language:Clojure 99.2%Language:Makefile 0.8%