fulcrologic / fulcro-spec Goto Github PK
View Code? Open in Web Editor NEWA library that wraps clojure.test for a better BDD testing experience.
License: MIT License
A library that wraps clojure.test for a better BDD testing experience.
License: MIT License
;; 3 assertions
user=> (do (time (macroexpand-1 '(c/assertions "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3))) :ok)
"Elapsed time: 1.66508 msecs"
:ok
;; 6 assertions
user=> (do (time (macroexpand-1 '(c/assertions "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "bye" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3))) :ok)
"Elapsed time: 7.626273 msecs"
:ok
;; 9 assertions
user=> (do (time (macroexpand-1 '(c/assertions "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "bye" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "adieu" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3))) :ok)
"Elapsed time: 26.759702 msecs"
:ok
;; 12 assertions
user=> (do (time (macroexpand-1 '(c/assertions "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "bye" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "adieu" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "qwerty" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3))) :ok)
"Elapsed time: 91.719407 msecs"
:ok
;; 24 assertions
user=> (do (time (macroexpand-1 '(c/assertions "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "bye" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "adieu" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "qwerty" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "hello" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "bye" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "adieu" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3 "qwerty" (inc 0) => 1 (inc 1) => 2 (inc 2) => 3))) :ok)
"Elapsed time: 14398.550569 msecs"
:ok
This doesn't hurt anything, but it does throw errors in the console.
Patch spec to work under those constraints to eliminate the noise that happens when running tests.
(deftest proposal-integration-test
(behavior "Some authorized user"
(assertions
"can add a new proposal to a process"
.... )))
; Output =>
; proposal-integration-test
; Some authorized user
;
; ^^^^^^ missing
If you embed assertions in a mocked function that fail, the errors will be shown ABOVE the outline (all green) instead of inline.
Steps to reproduce:
When a test fails, it starts showing all tests (at least for the failing ns). Once the test is fixed it still shows the non-focused ones.
So, when I'm working on SS tests on fulcro and rendering with browser, periodically on save I'll see the tests in core_spec.clj fail. Saving again causes them to succeed. My guess is that a refresh might be happening when a re-run gets triggered?
The fulcro-report reports twice the number of assertions.
Example:
(deftest foo
(is false))
default koacha reporter
1 tests, 1 assertions, 1 failures.
fulcro-spec.reporters.terminal/fulcro-report:
Ran 1 tests containing 2 assertions.
2 failures, 0 errors.
Same for assertions that do not fail.
See: https://cider.readthedocs.io/en/latest/indent_spec/
Currently CIDER formats the code in an unwanted way:
(behavior "failure retry"
(when-mocking ...))
After further investigation introducing these won't solve my immediate problem until this cljfmt issue get's resolved.
When using shadow-cljs, new tests are not picked up on hot code reload, removed tests do not disappear, and new namespaces that are tests are not found.
When I try to use the fulcro-spec server stuff to run them in the browser, I used to get weird errors which would say Could not find cloure.test.check.clojure-test
after some digging around I found the followin exception (which explains the error above).
17-08-25 13:27:30 mitsel ERROR [fulcro.server:276] - #:fulcro-spec.selectors{set-active-selectors #:om.next{:error java.lang.ClassCastException: fulcro_spec.reporter$fulcro_report$fn__66506 cannot be cast to clojure.lang.MultiFn, compiling:(clojure/test/check/clojure_test.cljc:119:1)}} Parser error:
{:status 400,
:body
#:fulcro-spec.selectors{set-active-selectors
#:om.next{:error
{:type
"class clojure.lang.Compiler$CompilerException",
:message
"java.lang.ClassCastException: fulcro_spec.reporter$fulcro_report$fn__66506 cannot be cast to clojure.lang.MultiFn, compiling:(clojure/test/check/clojure_test.cljc:119:1)"}}}}
I found this code in clojure.test.check
(let [begin-test-var-method (get-method ct/report #?(:clj :begin-test-var
:cljs [::ct/default :begin-test-var]))]
(defmethod ct/report #?(:clj :begin-test-var
:cljs [::ct/default :begin-test-var]) [m]
(reset! last-trial-report (get-current-time-millis))
(when begin-test-var-method (begin-test-var-method m))))
It seems to expect a multimethod. Would you accept a pull request that fixes this?
clojure.test
reporters depend on an event map to pretty-print failures. For an assertion that macro-expands to (is (= :foo :bar))
, Fulcro Spec is returning {:expected :foo}
instead of {:expected '(= :foo :bar)}
. This is a problem for any reporters that do not just print the error, but try to analyze it further (e.g. Kaocha that tries to pretty-print data diffs).
More details:
Maybe a workaround is to return the full expression in :expected
and use a different key for the expected-value that is used by the Fulcro reporters?
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.