Do not warn about subscriptions being used in non-reactive contexts (#17240)

Force re-frame to stop warning about subscriptions in non-reactive contexts
while executing subscription tests (i.e. unit tests using the macro
test-helpers.unit/deftest-sub).

The net result? No more hundreds of useless warnings in the output of make test.

    re-frame: Subscribe was called outside of a reactive context.
     See: https://day8.github.io/re-frame/FAQs/UseASubscriptionInAJsEvent/

The warning is actually useful in production code, but in a subscription test we
already know we're never inside a reactive context.
This commit is contained in:
Icaro Motta 2023-09-12 11:58:06 -03:00 committed by GitHub
parent 2c52001e22
commit 6ea31695d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -51,10 +51,12 @@
(let [~args [sub-name#]]
(restore-app-db
(fn []
~@(clojure.walk/postwalk-replace
{'cljs.test/testing `testing-subscription
'testing `testing-subscription}
body)))))))
;; Do not warn about subscriptions being used in non-reactive contexts.
(with-redefs [re-frame.interop/debug-enabled? false]
~@(clojure.walk/postwalk-replace
{'cljs.test/testing `testing-subscription
'testing `testing-subscription}
body))))))))
(defmacro use-log-fixture
"Register log fixture which allows inspecting all calls to `taoensso.timbre/log`.