【问题标题】:Shadow error when running the test runner运行测试运行器时出现阴影错误
【发布时间】:2021-01-10 07:26:53
【问题描述】:

我有以下 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."}

如何解决这个错误?

【问题讨论】:

    标签: react-native clojurescript shadow-cljs


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2015-07-17
      • 2011-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-21
      • 2021-10-20
      相关资源
      最近更新 更多