I am using this dependency: [cljsjs/react-input-autosize “2.2.1-1”]
and when run npx shadow-cljs compile app, it errs: The required namespace “cljsjs.react-input-autosize” is not available, it was required by “understanding_re_frame/hiccup.cljs”
However, I do see a ~/.m2/repository/cljsjs/react-input-autosize/2.2.1-1/react-input-autosize-2.2.1-1.jar file
what’s the further steps should I verify to see what’s going wrong?
> shadow-cljs does not support CLJSJS at all to avoid conflicts in your code https://shadow-cljs.github.io/docs/UsersGuide.html#_why_not_use_cljsjs
Thanks for that info.
Does shadow support this? http://clojurescriptmadeeasy.com/blog/refactoring-with-deprecation.html
@schpaencoder in the latest version you can set :devtools {:ignore-warnings true}
so this doesn't blow stuff up
or you can just turn off the warning completely
:compiler-options {:warnings {:fn-deprecated false}}
should work fine yes
https://github.com/clojure/clojurescript/commit/3ea593825f60c228f6a384be52bcf2fc4e417567
there is this ^
(def ^:dynamic cljs-warn-fn-deprecated true)
If I can do this with a simple binding, I would rather…
pretty sure that code doesn't exist anymore
oh well, I guess I just have to slow down a little then
whats the problem?
The problem is I don’t want to turn off warnings, but shadow complains about deprecations
then turn off that warning if you dont want to see that warning
Oh, sorry, Didn’t see the {:fn-deprecated false}
unless you still want to see it but not prevent hot reload and stuff. for that you can set :devtools {:ignore-warnings true}
Yes of course!
perfect!!
hello, everybody! I am relatively not new to clojureScript, but I am new to shadow-cljs, in particular how to configure testing properly. i have a 100% shadow-cljs project and I am struggling with the :node-test and :browser-test setups as they do not give me the desired output. Can maybe somebody give me an example of a project with shadow-cljs with properly configured testing? thank you in advance
Isn’t shadow supposed to automatically download the dependency? When I add https://github.com/day8/re-frame-10x as the project dependency, it errs: The required JS dependency “react-highlight.js” is not available, it was required by “day8/re_frame_10x/view/components.cljs”.
@marharyta.obraztsova what is the "desired output"?
@i did you restart after adding the dependency?
Yes. Now I manually add the dependency.
So, I am currently configuring :browser-test and the way I understand it (correct me if I am wrong) that this is the best way to set up testing for atoms and re-agent components
Initially I was not able to see the UI in the browser
as you can see now, I do, yet the panel on top shows 0 tests, o assertions
there it is
hmm not a clue about that. that display is from https://github.com/bhauman/cljs-test-display
yes, it is
according to the shadow-cljs docs I should not need it in the first place
because they have it intergrated
But I seem to need
need what?
... I seem to need it in my code to display the tests in the viasual way in the browser anyways
I'm confused. this is something you set up yourself?
yes, I did set it up myself
test.cljs
(ns mytherapy.test
(:require [cljs.test :refer (deftest is use-fixtures)]
[shadow.dom :as dom]
[shadow.test :as st]
[cljs-test-display.core :as ctd]
["react-testing-library" :as rtl]
[cljs-time.core :as time]
[mytherapy.state-utils :refer [state-app make-note]]
))
;; <https://gist.github.com/cdbkr/f195d7fbb600fae9655f37e7b2b4813e>
(use-fixtures :each
{:after rtl/cleanup})
(def test-state {:notes []
:records []
:data []
:currentNote {}})
(deftest a-failing-test
(is (= 2 2)))
(deftest a-failing-test-6
(is (= 9 2)))
(deftest test-make-note
(is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
:note_title "hello"
:note_type "note"
:timestamp_created "20210119T164619"
:timestamp_edited "20210119T164619"})))
(defn start []
(st/run-all-tests (ctd/init! "test-root"))
(a-failing-test)
(a-failing-test-6)
(test-make-note))
(defn stop[done]
; tests can be async. You must call done so that the runner knows you actually finished
(done))
(defn ^:export init[]
(dom/append [:div#test-root])
(start))
why did you do that?
because otherwise I see blank page
if the test file looks like this:
the test file should just contain deftest
and so on
(ns mytherapy.test
(:require [cljs.test :refer (deftest is use-fixtures)]
[shadow.dom :as dom]
[shadow.test :as st]
[cljs-test-display.core :as ctd]
["react-testing-library" :as rtl]
[cljs-time.core :as time]
[mytherapy.state-utils :refer [state-app make-note]]
))
;; <https://gist.github.com/cdbkr/f195d7fbb600fae9655f37e7b2b4813e>
(use-fixtures :each
{:after rtl/cleanup})
(def test-state {:notes []
:records []
:data []
:currentNote {}})
(deftest a-failing-test
(is (= 2 2)))
(deftest a-failing-test-6
(is (= 9 2)))
(deftest test-make-note
(is (= (make-note "uhihy" "hello" "20210119T164619") {:note_id "uhihy"
:note_title "hello"
:note_type "note"
:timestamp_created "20210119T164619"
:timestamp_edited "20210119T164619"})))
(defn start []
(a-failing-test)
(a-failing-test-6)
(test-make-note))
(defn stop[done]
; tests can be async. You must call done so that the runner knows you actually finished
(done))
(defn ^:export init[]
(start))
nothing related to runner stuff. that is completely optional. I guess the docs should make that clearer.
then i see blank page
remove start/stop/init completely
It says I should do that in the docs
and do NOT specify a :runner-ns
in your build config
https://shadow-cljs.github.io/docs/UsersGuide.html#target-browser-test
hmm, I can try it
yeah I'll clear that up. :runner-ns (optional)
this is definitely not clear enough 😛
after deleting :runner-ns I see nothing
ok now you likely need to delete the index.html
you created
shadow-cljs will generate a new one (when you start the watch)
Same here
{...
:builds
{:test
{:target :browser-test
:test-dir "test-out"
:ns-regexp "-test$"
:devtools {:http-port 8021
:http-root "test-out"}}}}
try this. just in case there are files or whatever in the old :test-dir
interfering with stuff
note that the test ns likely needs to be changed as the regexp above is for files ending in -test
so mytherapy.test
wouldn't match that
perfect!
Thanks a lot @thheller!