untangled-web / untangled-spec Goto Github PK
View Code? Open in Web Editor NEWA Behavioral Specification Testing Library for Clojure and Clojurescript
License: MIT License
A Behavioral Specification Testing Library for Clojure and Clojurescript
License: MIT License
▼DIFF
#object[Function "function (coll,k,v){ var coll__$1 = this;
throw cljs.core.ex_info.call(null,"cljs.core/List is not
cljs.core/IAssociative",cljs.core.PersistentArrayMap.EMPTY); }"]
Should perhaps contains some examples & point to the dev guide or the appropriate docs/*.adoc
Warning: React.createElement(...): Expected props argument to be a plain object.
printWarning @ react.inc.js:20483
warning @ react.inc.js:20507
ReactElement.createElement @ react.inc.js:10609
createElement @ react.inc.js:10950
om.dom.span.cljs$core$IFn$_invoke$arity$variadic @ dom.cljs?rel=1480629449852:9
om$dom$span @ dom.cljs?rel=1480629449852:9
untangled_spec$dom$edn_renderer$clearfix_separator_STAR_ @ edn_renderer.cljs?rel=1480629449980:25
(anonymous function) @ edn_renderer.cljs?rel=1480629449980:34
cljs.core.repeatedly.cljs$core$IFn$_invoke$arity$1 @ core.cljs:4603
cljs.core.LazySeq.sval @ core.cljs:3223
cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 @ core.cljs:3277
cljs$core$seq @ core.cljs:1107
cljs.core.interleave.cljs$core$IFn$_invoke$arity$2 @ core.cljs:4615
cljs.core.LazySeq.sval @ core.cljs:3223
cljs.core.LazySeq.cljs$core$ISeqable$_seq$arity$1 @ core.cljs:3277
cljs$core$seq @ core.cljs:1107
cljs.core.Cons.cljs$core$INext$_next$arity$1 @ core.cljs:3065
cljs$core$next @ core.cljs:1152
cljs$core$to_array @ core.cljs:3445
untangled_spec$dom$edn_renderer$interpose_separator @ edn_renderer.cljs?rel=1480629449980:33
untangled_spec$dom$edn_renderer$join_html @ edn_renderer.cljs?rel=1480629449980:48
untangled_spec$dom$edn_renderer$html_collection @ edn_renderer.cljs?rel=1480629449980:70
untangled_spec$dom$edn_renderer$html @ edn_renderer.cljs?rel=1480629449980:95
untangled_spec.dom.edn_renderer.html_edn.cljs$core$IFn$_invoke$arity$variadic @ edn_renderer.cljs?rel=1480629449980:122
untangled_spec$dom$edn_renderer$html_edn
Check that we can use test selectors in cljs.test.
Maybe we can output tests only if -Dtest-selector=...
.
eg:
Where: (__Form-config-and-state-helpers__) (at http:432:14)
should be more like
Where: (__Form-config-and-state-helpers__) (at forms:##:##)
TypeError cannot read property call of null in reconcile!, when trying to ((:render st))
Try:
(assertions
(under-test) =fn=> #(do (assertions ... => ...) true))
Crashes with read-string in print-message reporters/terminal.clj#L109
(untangled-spec.reporters.impl.diff/diff
{:current-tab [:messages :tab], :ui/loading-data false}
{:current-tab [:settings :tab], :ui/loading-data false})
evaluates to {}
expected {[:current-tab 0] [:+ :messages :- :settings]}
EX: Mocking a function with an =>
arrow, should report more than a vague error about it not being called the right number of times when it is actually called more than once but with incorrect number of arguments.
;; SRC
(defn foo [& xs] (first x))
;; TEST
(when-mocking
(foo arg1) => arg1
(assertions (do (foo 1) (foo 2 3)) => :what?))
Proposed error message should show the mock invocation history and therefore have more information about the failing case.
(assertions [1 2] => 3)
=>
core.cljs:5103 Uncaught Error: Vector's key for assoc must be a number.
cljs.core.PersistentVector.cljs$core$IAssociative$_assoc$arity$3 @ core.cljs:5103
cljs$core$_assoc @ core.cljs:534
cljs.core.assoc.cljs$core$IFn$_invoke$arity$3 @ core.cljs:1860
cljs$core$assoc_in @ core.cljs:4818
(anonymous function) @ edn_renderer.cljs?rel=1480719314221:110
(anonymous function) @ core.cljs:2314
cljs.core.seq_reduce.cljs$core$IFn$_invoke$arity$3 @ core.cljs:2314
cljs.core.PersistentArrayMap.cljs$core$IReduce$_reduce$arity$3 @ core.cljs:6282
cljs.core.reduce.cljs$core$IFn$_invoke$arity$3 @ core.cljs:2358
cljs$core$reduce @ core.cljs:2329
untangled_spec$dom$edn_renderer$apply_diff @ edn_renderer.cljs?rel=1480719314221:107
untangled_spec.dom.edn_renderer.html_edn.cljs$core$IFn$_invoke$arity$variadic @ edn_renderer.cljs?rel=1480719314221:121
untangled_spec$dom$edn_renderer$html_edn @ edn_renderer.cljs?rel=1480719314221:117
ie:
ACT: "4 days ago"
EXP: "6 days ago"
DIFFS:
act: "4 days ago"
exp: "6 days ago"
is useless and just clutters the page.
eg:
;core.clj
(ns us-core)
(defmacro ...)
;core.cljs
(ns core (:require-macros [us-core]))
The code example in 1.2: Clojure in the browser doesn't work with the latest non-alpha version (0.4.0
) — untangled-spec.selectors
and untangled-spec.suite
don't exist in that version, so the :require
clause fails. Since the latest version is currently an alpha, would it make sense to provide a corresponding version of the example for 0.4.0
?
When mocking we should validate the return value based on a potential :ret spec on the function we are mocking.
NOTE: use s/get-spec on the var, eg: (-> sum var s/get-spec :ret (s/valid? ...))
NOTE: It may not be a function, as we may be supporting protocols &/or inline (& maybe others)
(s/fdef sum :ret number?)
(defn sum [& xs] (apply + xs))
(when-mocking
(sum 0 1 2) => "3"
...)
;=> fails because it failed the sum :ret spec (not a number?)
Can maybe #13 be solved first/instead?
(assertions
"sample"
`[({:prop []} {:n 1})] => `[({:prop []} {:n 2})])
crashes in 0.3.9
core.cljs:270 Uncaught Error: No protocol method IAssociative.-assoc defined for type cljs.core/Cons: ({:prop []} {:n 1})
Also getting a core.cljs:264 Uncaught Error: No protocol method IAssociative.-assoc defined for type cljs.core/IndexedSeq: (2 :evil)(…)
when testing something like ((fn [& args] args) 2 3) => [1 2]
in the stub machinery.
Trying to do lein test-refresh, lein repl etc when requiring untangled-spec suite in my user namespace causes an exception. I don't use or require it anywhere else.
(ns user
(:require
[untangled-spec.suite :as suite]))
Exception in thread "main" java.lang.ExceptionInInitializerError
at clojure.main.<clinit>(main.java:20)
Caused by: java.lang.RuntimeException: No such var: find/find-sources-in-dir, compiling:(clojure/tools/namespace/dir.clj:26:17)
My project.clj:
(defproject imperimetric "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.9.0-alpha14"]
[org.clojure/clojurescript "1.9.495"]
[reagent "0.6.0"]
[binaryage/devtools "0.8.3"]
[re-frame "0.9.1"]
[secretary "1.2.3"]
[cljs-ajax "0.5.8"]
[compojure "1.5.1"]
[instaparse "1.4.3"]
[liberator "0.14.1"]
[medley "0.8.4"]
[frinj "0.2.5"]
[cheshire "5.6.3"]
[yogthos/config "0.8"]
[cljsjs/clipboard "1.5.13-0"]
[ring "1.5.0"]
[ring/ring-mock "0.3.0"]
[org.clojure/tools.namespace "0.3.0-alpha3"]
[devcards "0.2.2"]]
:uberjar-name "imperimetric-standalone.jar"
:plugins [[lein-cljsbuild "1.1.5"]
[lein-less "1.7.5"]
[lein-kibit "0.1.3"]]
:min-lein-version "2.5.3"
:source-paths ["src/clj"]
:clean-targets ^{:protect false} ["resources/public/js/compiled" "target"
"test/js"]
:figwheel {:css-dirs ["resources/public/css"]
:nrepl-host "0.0.0.0"
:nrepl-port 7888
:nrepl-middleware ["cemerick.piggieback/wrap-cljs-repl"]}
:less {:source-paths ["less"]
:target-path "resources/public/css"}
:hooks [leiningen.less]
:profiles
{:dev
{:dependencies [[pjstadig/humane-test-output "0.8.1"]
[figwheel-sidecar "0.5.0"]
[com.cemerick/piggieback "0.2.1"]
[org.clojure/test.check "0.9.0"]
[navis/untangled-spec "1.0.0-alpha3"]]
:plugins [[lein-figwheel "0.5.4-3"]
[lein-doo "0.1.7"]
[com.jakemccrary/lein-test-refresh "0.19.0"]]
}}
:uberjar {:aot :all}
:cljsbuild
{:builds
[{:id "dev"
:source-paths ["src/cljs"]
:figwheel {:on-jsload "imperimetric.core/mount-root"}
:compiler {:main imperimetric.core
:output-to "resources/public/js/compiled/app.js"
:output-dir "resources/public/js/compiled/out"
:asset-path "js/compiled/out"
:source-map-timestamp true}}
{:id "min"
:source-paths ["src/cljs"]
:jar true
:compiler {:main imperimetric.core
:output-to "resources/public/js/compiled/app.js"
:optimizations :advanced
:closure-defines {goog.DEBUG false}
:pretty-print false}}
{:id "devcards"
:source-paths ["src/devcards" "src/cljs"]
:figwheel {:devcards true}
:compiler {:main imperimetric.core-card
:output-to "resources/public/js/compiled/devcards.js"
:output-dir "resources/public/js/compiled/devcards_out"
:asset-path "js/compiled/devcards_out"
:source-map-timestamp true}}
{:id "test"
:source-paths ["src/cljs" "test/cljs"]
:compiler {:output-to "resources/public/js/compiled/test.js"
:main imperimetric.runner
:optimizations :none}}
]}
:main imperimetric.server
:aot [imperimetric.server]
:prep-tasks [["cljsbuild" "once" "min"] "compile"]
)
Cannot seem to find what the issue is, I'm assuming the issue is not with tools.namespace itself.
When running tests (0.3.10-SNAPSHOT) I'm getting zero counts when tests have obviously run.
EX:
=throws=> ExceptionInfo
=throws=> {:type ,,, :regex ,,, :fn ,,,}
It's much easier, when project has description and you can fast understand purpose.
And it's a little bit sad, when "No description or website provided." appears.
Anyway, great work guys
[untangled-spec.reporters.impl.diff :refer [diff]]
(diff {:current-tab [:bookings :tab],
:search-results {:global {:es-type "booking"}}}
{:current-tab [:messages :tab],
:search-results {:global {:es-type "message"}}})
evaluates to
{[:search-results :global :es-type] [:+ "booking" :- "message"]}
tested on 0.3.8
There should be a way to leverage existing libraries/tools to parse stack traces to make them:
So it shows up near the test reporting, so we can debug easier than just printing and having them bunch up at the top with no clear way to tell where it came from.
Maybe just a with-out-str
? Try to solve issue #13 first?
(ns spec-playground.core-test
(:require
[clojure.test :as t]
[spec-playground.core :refer :all]
[untangled-spec.core :refer [specification behavior component assertions]]))
(t/deftest a-test
(t/testing "FIXME, I fail."
(t/is (= 2 1) "AMLAKDF")))
(specification "arithmetic"
(component "addition"
(behavior "is commutative"
(assertions
(+ 13 42) => (+ 42 13)))))
Results in the following outline
*********************************************
*************** Running tests ***************
:reloading (spec-playground.core-test)
Running tests for: (spec-playground.core-test)
Testing spec-playground.core-test ;; FAILING
arithmetic ;; PASSING
addition ;; PASSING
is commutative ;; PASSING
Ran 2 tests containing 2 assertions.
1 failures, 0 errors.
Failed 1 of 2 assertions
Finished at 11:33:56.296 (run time: 0.027s)
(defn sum [& args] (apply + args))
(when-mocking
(sum x & z) => (do (assertions x => 1, z => [2 3]) :ok)
(assertions
(sum 1 2 3) => :ok))
(some-response) =fn=> (matches? {:status 200, :body file?})
Creates a fn that takes a value and checks it against a spec,
values in the spec become like a =>, if it's a it's like a =fn=>, etc...
Merge the rendering, split the running of tests so that we just send data to the renderer about the test results.
See develop...experimental/rendering-merge previously (unlinked) commits.
(s/def ::thing (s/cat :a (s/? string?) :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of (list ”foo” 1 “bar” 2 3 “qux” 4))
;=> [{:a "foo", :b [1]} [{:a "bar", :b [2 3]} {:a "qux", :b [4]}]]
;EXPECTED
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
;; ONLY 2nd thing matters?
(s/conform ::seq-of (list ”foo” 1 2 “bar" 3))
;=> [{:a "foo", :b [1 2]} {:a "bar", :b [2]}]
;; NO OPTIONAL
(s/def ::thing (s/cat :a string? :b (s/+ number?)))
(s/def ::seq-of (s/+ ::thing))
(s/conform ::seq-of (list ”foo” 1 “bar” 2 3 “qux” 4))
;=> [{:a "foo", :b [1]} {:a "bar", :b [2 3]} {:a "qux", :b [4]}]
This also only shows up if there are 2+ numbers in the 2nd or later ::thing
AND the problem goes away if I make :a not optional…
is this at all related to http://dev.clojure.org/jira/browse/CLJ-2003 ?
POSTED TO: http://dev.clojure.org/jira/browse/CLJ-2105
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.