0

我有以下 shadow-cljs.edn 文件。我正在尝试从浏览器中的测试目录运行测试:

{: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]}}}}

我正在尝试从以下文件运行测试:

(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))

但是在 repl 上运行 (shadow/watch :test) 时,我收到以下错误:

(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."}

如何修复此错误?

4

1 回答 1

2

您不能react-native使用其中一个:browser-test:node-test目标运行测试。

这些react-native包必须由metro使用的捆绑器编译,react-native因为它们包含 shadow-cljs 不直接支持的代码(例如流、打字稿等)。

于 2021-01-10T11:39:33.677 回答