Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

react native - Shadow error when running the test runner

I have the following shadow-cljs.edn file. And I'm trying to run tests from a test directory in the browser:

{:deps true
 :source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "0.12.0"]
                [re-frame-steroid "0.1.1"]
                [rn-shadow-steroid "0.2.1"]
                [re-frisk-remote "1.3.3"]
                [cljs-ajax/cljs-ajax "0.8.1"]
                [day8.re-frame/http-fx "0.2.2"]]

 :builds
 {:test {:target :browser-test
         :test-dir "test/humboi"
         :runner-ns humboi.core
         :devtools  {:http-port          8021
                     :http-root          "test/humboi"}
         }
  :dev
  {:target     :react-native
   :init-fn    humboi.core/init
   :output-dir "app"
   :compiler-options {:closure-defines
                      {"re_frame.trace.trace_enabled_QMARK_" true}}
   :devtools   {:after-load steroid.rn.core/reload
                :build-notify steroid.rn.core/build-notify
                :preloads [re-frisk-remote.preload]}}}}

And I'm trying to run tests from the following file:

(ns humboi.core-test
  (:require [humboi.core :as sut]
            ["@testing-library/react-native" :refer [render fireEvent]]
            [humboi.auth.core :refer [google-sign-in-comp]]
            [cljs.test :as t :include-macros true]))

(defn mount! [component]
  (render (r/as-element component)
          #js {:container (testing-container)}))

(deftest google-login-test
  (is (mount! [google-sign-in-comp])))

(defn start [] (cljs.test/run-tests))

(defn stop [done]
  ;; stopping the tests
  (done))

(defn ^:export init []
  (start))

But on running (shadow/watch :test) on the repl, I'm getting the following error:

(shadow/watch :test)
[:test] Configuring build.
[:test] Compiling ...
[:test] Build failure:
Failed to inspect file
  /Users/prikshetsharma/Desktop/Humboi/node_modules/react-native/index.js

Errors encountered while trying to parse file
  /Users/prikshetsharma/Desktop/Humboi/node_modules/react-native/index.js
  {:line 13, :column 7, :message "cannot use keyword 'typeof' here."}

How to fix this error?

question from:https://stackoverflow.com/questions/65650990/shadow-error-when-running-the-test-runner

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You cannot running react-native tests using the either :browser-test or :node-test targets.

The react-native packages must be compiled by the metro bundler used by react-native as they contain code not supported by shadow-cljs directly (eg. flow, typescript, etc).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...