This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-03
Channels
- # aws (12)
- # beginners (12)
- # biff (10)
- # calva (1)
- # cider (10)
- # cljfx (1)
- # clojure (2)
- # clojure-conj (1)
- # clojure-europe (25)
- # clojure-madison (1)
- # clojure-nl (1)
- # clojure-norway (12)
- # clojure-sweden (4)
- # clojure-uk (6)
- # datomic (11)
- # dev-tooling (3)
- # emacs (5)
- # gratitude (1)
- # introduce-yourself (7)
- # java (3)
- # jobs (1)
- # london-clojurians (2)
- # lsp (23)
- # off-topic (4)
- # practicalli (9)
- # quil (6)
- # re-frame (3)
- # reagent (4)
- # remote-jobs (1)
- # ring (1)
- # shadow-cljs (18)
- # squint (67)
- # tools-deps (5)
- # xtdb (4)
- # yamlscript (12)
Hi all! I am starting to write tests for my re-frame app. I have read all the docs on testing. I have decided to be using day8.re-frame/test to test the whole system in addition to standard unit tests of particular handlers and have the following question:
I use effects to do http queries and some custom effects to do some other stuff. How can I mock effects? What I mean is that when I do http query the effect dispatches some events on success/failure and I would like them to be dispatched with mocked data and possibly a delay. I use rf-test/run-test-async, but still no idea how to mock effects. I use [day8.re-frame/http-fx "0.2.4"] for http.
Everything in re-frame that you register with reg-*
functions can be registered again, overriding the previous value.
So if somewhere you have
(rf/reg-fx :http the-actual-handler)
you can do
(rf/reg-fx :http the-mocked-version)
as a preparation step for tests. But note that it's a global registry, there's no way to mock it per-test or unmock it without re-registering the original handler.