This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-24
Channels
- # aleph (4)
- # beginners (93)
- # cider (7)
- # cljs-dev (16)
- # cljsrn (5)
- # clojure (192)
- # clojure-dusseldorf (3)
- # clojure-italy (14)
- # clojure-russia (16)
- # clojure-serbia (1)
- # clojure-spec (85)
- # clojure-taiwan (1)
- # clojure-uk (79)
- # clojurescript (188)
- # code-reviews (9)
- # core-async (2)
- # crypto (1)
- # cursive (26)
- # datomic (21)
- # heroku (1)
- # hoplon (3)
- # jobs (7)
- # jobs-discuss (20)
- # jobs-rus (13)
- # off-topic (77)
- # om (15)
- # onyx (23)
- # pedestal (94)
- # planck (11)
- # proton (10)
- # protorepl (1)
- # re-frame (16)
- # ring (22)
- # ring-swagger (9)
- # rum (2)
- # specter (18)
- # testing (2)
- # untangled (14)
- # vim (12)
- # yada (58)
Have anyone found a good way to test cljsrn
apps? Preferably using spec
? Any tips would be appreciated. I’m thinking I can use test.check
for all non-react functions, but I’d like to do UI testing (probably end-to-end) too.
@seantempesta What we’re doing is using enzyme and shallow-render the components. That will not generate anything useful but at least it will throw if there are any js-errors. But fb have released a new snapshot test feature for jest that would probably be more useful: https://facebook.github.io/jest/docs/tutorial-react-native.html
We’re doing this for spec tests:
(defmacro generative-tests
"Takes a list of fn symbols and runs generative tests on them"
[fn-syms]
`(let [opts# {:clojure.test.check/opts
{:num-tests 1}}
long-res# (cljs.spec.test/check ~fn-syms opts#)
res# (cljs.spec.test/summarize-results
long-res#)]
(cljs.test/is (-> ~fn-syms
empty?
not)
"A namespace was empty")
(cljs.test/is (not (or (:check-failed res#)
(:check-threw res#)
(:instrument res#))) (str "Spec failed for "
(map :sym (filter :failure long-res#))))))
(s/fdef generative-tests
:args (s/cat :syms (s/coll-of any?)))
(defn- gen-test
([n] (gen-test n #{}))
([n {:keys [exclude]}]
`(generative-tests (clojure.set/difference
(enumerate-namespace ~n)
~exclude))))
(defmacro gen-test-ns
"Takes a ns and optionally excluded syms and runs generative tests for all the
functions"
[& args]
(apply gen-test args))
I wish he could share more of the technical details