                                             (done)))))
 
   (testing "dispatch! an non-existing event fails"
-    (is (thrown-with-msg? js/Error
-                          #"Assert failed: Controller :test doesn't declare :non-existing-dispatch method"
-                          (citrus/dispatch! r :test :non-existing-dispatch)))))
+    (let [err-handler (fn [err] (is (re-find #"No method .* for dispatch value: :non-existing-dispatch" (.toString err))))]
+      (obj/set js/window "onerror" err-handler)
+      (citrus/dispatch! r :test :non-existing-dispatch)
+      (async done (js/requestAnimationFrame (fn []
+                                              (obj/set js/window "onerror" nil)
+                                              (done)))))))
 
 
 (deftest broadcast!


  (testing "broadcast-sync! a non-existing event fails"
    (is (thrown-with-msg? js/Error
                          #"Assert failed: Controller :test doesn't declare :non-existing-event method"
                          (citrus/broadcast-sync! r :non-existing-event)))))



                                            (done)))))

  (testing "broadcast! an non-existing event fails"
    (let [err-handler (fn [err] (is (re-find #"No method .* for dispatch value: :non-existing-broadcast" (.toString err))))]
      (obj/set js/window "onerror" err-handler)
      (citrus/broadcast! r :non-existing-broadcast)
      (async done (js/requestAnimationFrame (fn []
                                              (obj/set js/window "onerror" nil)
                                              (done)))))))

(deftest dispatch-nil-state-issue-20
  ;https://github.com/roman01la/citrus/issues/20
