Fork me on GitHub
Mark Gerard17:07:37

Hey! Could someone help me with this error?

expected: (= "2020" (->> (r/as-element [footer-component]) (rtl/render) (.getByText "copyright") (.-innerHTML)))
  actual: #object[ReferenceError ReferenceError: document is not defined]
I am trying to test drive my component, and here is the component def:
(ns components.footer-test
   [reagent.core :as r]
   ["@testing-library/react" :as rtl]
   [components.footer :refer [footer-component]]
   [cljs.test :refer [deftest testing is use-fixtures]]))

(deftest test-that-copyright-has-correct-year
  (testing "Test Correct year in copyright"
      (-> (r/as-element [footer-component])
          (.getByText "copyright")
What might be the issue? Do I need to call some function to init the document?


Always look at the stacktrace. If it ends up in some JS library, then chances are that the problem is with the usage of that library and not with the CLJS code itself.

Mark Gerard17:07:22

I know it is not a problem with CLJS ....


Well, either way that issue has a fix.

Mark Gerard17:07:41

changed :target :node-test to :target browser-test. Got it working, thanks a bunch @U2FRKM4TW

👍 3