From 6ea31695d6076aee0e24198c1e6186c17c9f8009 Mon Sep 17 00:00:00 2001 From: Icaro Motta Date: Tue, 12 Sep 2023 11:58:06 -0300 Subject: [PATCH] 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. --- src/test_helpers/unit.clj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/test_helpers/unit.clj b/src/test_helpers/unit.clj index 1625898c4c..9c613be382 100644 --- a/src/test_helpers/unit.clj +++ b/src/test_helpers/unit.clj @@ -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`.