reagent

A minimalistic ClojureScript interface to React.js http://reagent-project.github.io/
2020-07-31T05:38:36.077900Z

Yeah check track! then. https://github.com/reagent-project/reagent/blob/master/doc/ManagingState.md

Mark Gerard 2020-07-31T17:25:37.079900Z

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
  (:require
   [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"
    (is
     (=
      "2020"
      (-> (r/as-element [footer-component])
          (rtl/render)
          (.getByText "copyright")
          (.-innerHTML))))))
What might be the issue? Do I need to call some function to init the document?

p-himik 2020-07-31T17:30:01.080500Z

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 Gerard 2020-07-31T17:31:22.080700Z

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

p-himik 2020-07-31T17:32:23.080900Z

Well, either way that issue has a fix.

Mark Gerard 2020-07-31T17:32:40.081100Z

Checking ...

Mark Gerard 2020-07-31T17:49:41.081300Z

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

1👍