Utilities for writing async tests for both clj and cljs (cljc).
In deps.edn
:
{net.r4s6/test-async {:mvn/version "0.2.0"}}
In your tests:
(ns your-tests
(:require
[clojure.test :as t]
[net.r4s6.test-async :as a :include-macros true]))
(t/deftest something
(a/async
done
(a/async-redefs
[some/var new-value]
reset-redefs
(pass (juxt reset-redefs done) to something async)))
Works just like cljs.test/async
(async
done
(do
...
(done))
In this example done
is the name that the callback function
will be bound to in the body.
Like clojure.core/with-redefs
but instead of restoring defs at the end of the
block it defines a callback function that your block should call when finished
(similar to the way async
works) that will restore the vars.
(async-redefs
[some-var new-value]
reset-redefs
(do
...
(reset-redefs))
In this example reset-redefs
is the name that the callback function
will be bound to in the body.
Configure the timeout for async tests (default is 10000ms).
(with-timeout 30000
(async
...))
Alternatively you can set *timeout*
globally.
Copyright © 2021 Randy Stauner
Distributed under the Eclipse Public License version 1.0.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close