Hi everyone,

I'm very excited to announce kamera <https://github.com/oliyh/kamera>, a 
visual testing tool for Clojure.

>  

> When data is represented visually for a human to view you must take to 
> present it intuitively, accessibly and beautifully. This requires skill, 
> time and above all human judgement.
> Once achieved you want to ensure it does not suffer regressions. kamera is 
> a library designed to help you capture and compare screenshots of your 
> application, failing if there is too much divergence between an expected 
> reference image and the current display and creating a diffference image to 
> show you where.
> The best way to test visual representation is to create devcards 
> <https://github.com/bhauman/devcards> which you can use to display 
> components in as many states as possible. If you ensure you separate 
> rendering from business logic you can ensure that refactoring will not 
> affect them and prevent them becoming brittle - I outlined this approach in 
> a blog post for JUXT <https://juxt.pro/blog/posts/cljs-apps.html>.


If you don't use figwheel or devcards you can still use kamera to take 
screenshots and compare them to reference images - click here to see how 
<https://github.com/oliyh/kamera#core-api>.

If you do use devcards then testing them all is simple! If you have the 
following devcards files:

test
└── example
    ├── another_core_test.cljs
    └── core_test.cljs

... and a directory populated with reference images, named in the same way:

test-resources
└── kamera
    ├── example.another_core_test.png
    └── example.core_test.png

... you can get kamera to screenshot the devcards and compare with the 
corresponding reference images with the following:

(ns example.devcards-test
  (:require [kamera.devcards :as kd]
            [clojure.test :refer [deftest testing is]]))

(deftest devcards-test
  (kd/test-devcards "dev" kd/default-opts))

The output will look like this:

Results

example.kamera-test1 non-passing tests:

Fail in devcards-test#!/example.another_core_test
example.another_core_test.png has diverged from reference by 0.020624, please 
compare
Expected: test-resources/kamera/example.another_core_test.png
Actual: target/kamera/example.another_core_test.png
Difference: target/kamera/example.another_core_test-difference.png
expected: (< metric metric-threshold)

  actual: (not (< 0.020624 0.01))

The target directory will contain an expected, actual and difference image 
for every devcard. The three files referenced above will look like this:
<https://github.com/oliyh/kamera/blob/master/doc/juxtaposed.png?raw=true> 
There are loads of options <https://github.com/oliyh/kamera#options> to let 
you choose what metrics to use, filter out devcards you don't want to test, 
normalisations to apply etc.

I hope you find it useful! Let me know if you have any questions. Issues, 
feature requests and PRs can be submitted via GitHub.

Cheers,
Oliy

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to