has anyone used react native testing library with shadow-cljs?
How did you integrate the tests?
I would like to import js-notications, the exact syntax is not in shadow-cljs doc
import ToastManager from 'js-notifications';
const toastManager = new ToastManager();
(:require ["js-notifications" :refer (ToastManager)] )
(.ToastManager. {}) -> module$node_modules$js_notifications$dist$ToastManager.ToastManager is not a constructorthe exact syntax is in the docs, see the translation table https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
The exact pattern is not in the docs. I tried them all, but after lunch I might found the solution, it looks promising - no errors (It is not logical to me at all)
import ToastManager from 'js-notifications';
->
["js-notifications" :default ToastManager]
I see that one as the first row in the table
this "default" is confusing to me. When npm exports some objects, is there one default? or defaultExport is just a name and :default just picks an object from map of all exported objects?
import defaultExport from "module-name";
it is right there in the first example 😛
the name is up to you. you choose it. defaultExport
is the name
can be anything
default exports are "new" in ESM and are somewhat special
technically you can also :as x
and x/default
but thats kinda lame
I’m getting the following error when running shadow watch
Invalid configuration -- Spec failed -------------------- {:target ..., :output-dir ..., :entries [], ^^ :build-id ...} should satisfy (<= 1 (count %) Integer/MAX_VALUE) -- Relevant specs ------- :shadow.build.targets.npm-module/entries: (clojure.spec.alpha/coll-of clojure.core/simple-symbol? :distinct true :min-count 1 :kind clojure.core/vector?) :shadow.build.targets.npm-module/target: (clojure.spec.alpha/keys :req-un [:shadow.build.targets.shared/output-dir :shadow.build.targets.npm-module/entries] :opt-un [:shadow.build.targets.npm-module/runtime :shadow.build.targets.shared/devtools]) :shadow.build.config/build+target: (clojure.spec.alpha/and :shadow.build.config/build (clojure.spec.alpha/multi-spec shadow.build.config/target-spec :target)) ------------------------- Detected 1 error
{: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 :npm-module :output-dir “test-out” :entries []} :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]}}}}
i’m running the command shadow-cljs watch test
the error tells you that :entries []
is not valid and requires at least one namespace
I put in a namespace myapp.core-test but it says that the namespace wasn’t found
not available
I expect that the namespace would be available
since the namespace is defined in one of the files in the source-paths
the source path is “test”
and the file with this namespace is found in the path ./test/myapp
:deps true
. do you have "test"
added in :paths
in deps.edn
?
I’ve added test in :source-paths in deps.edn
What about clj->js? I was quite naive, that the npm import has magic powers and will also convert clojure stuctures to js. But I found that this is not the case and clj->js is still a must, It would be great id clj-kondo would be able to recognize cases like that. I spent at least an hour before I find out that my options are silently ignored without conversion. (def tm (ToastManager. (clj->js {:container log-container, :seconds 300})))
@jj974 this is impossible to know for clj-kondo I think, which JS libs accept data CLJS structures and which do not (even if most of them don't)
@ps :source-paths
is not a thing in deps.edn
. it is :paths
or :extra-paths
@borkdude clj-kondo is great. I cleaned up my old project. Learned a few things, misplaced doc strings, way too many times.
:)