Fork me on GitHub
#shadow-cljs
<
2021-01-19
>
pinkfrog00:01:28

I am using this dependency: [cljsjs/react-input-autosize “2.2.1-1”]

pinkfrog00:01:54

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”

pinkfrog00:01:56

However, I do see a ~/.m2/repository/cljsjs/react-input-autosize/2.2.1-1/react-input-autosize-2.2.1-1.jar file

pinkfrog00:01:09

what’s the further steps should I verify to see what’s going wrong?

dpsutton00:01:41

> 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

pinkfrog13:01:21

Thanks for that info.

thheller13:01:24

@schpaencoder in the latest version you can set :devtools {:ignore-warnings true} so this doesn't blow stuff up

thheller13:01:32

or you can just turn off the warning completely

thheller13:01:03

:compiler-options {:warnings {:fn-deprecated false}} should work fine yes

Schpaa13:01:27

there is this ^

Schpaa13:01:37

(def ^:dynamic cljs-warn-fn-deprecated true)

Schpaa13:01:07

If I can do this with a simple binding, I would rather…

thheller13:01:52

pretty sure that code doesn't exist anymore

Schpaa13:01:50

oh well, I guess I just have to slow down a little then

thheller13:01:10

whats the problem?

Schpaa13:01:11

The problem is I don’t want to turn off warnings, but shadow complains about deprecations

thheller13:01:34

then turn off that warning if you dont want to see that warning

Schpaa13:01:18

Oh, sorry, Didn’t see the {:fn-deprecated false}

thheller13:01:24

unless you still want to see it but not prevent hot reload and stuff. for that you can set :devtools {:ignore-warnings true}

Schpaa13:01:27

Yes of course!

Margo14:01:33

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

pinkfrog16:01:46

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”.

thheller16:01:48

@marharyta.obraztsova what is the "desired output"?

Margo18:01:51

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

Margo18:01:08

Initially I was not able to see the UI in the browser

Margo18:01:14

as you can see now, I do, yet the panel on top shows 0 tests, o assertions

Margo18:01:38

there it is

thheller18:01:06

hmm not a clue about that. that display is from https://github.com/bhauman/cljs-test-display

Margo18:01:38

yes, it is

Margo18:01:15

according to the shadow-cljs docs I should not need it in the first place

Margo18:01:24

because they have it intergrated

Margo18:01:29

But I seem to need

Margo18:01:10

... I seem to need it in my code to display the tests in the viasual way in the browser anyways

thheller18:01:47

I'm confused. this is something you set up yourself?

Margo18:01:02

yes, I did set it up myself

Margo18:01:28

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


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

thheller18:01:38

why did you do that?

Margo18:01:56

because otherwise I see blank page

Margo18:01:13

if the test file looks like this:

thheller18:01:50

the test file should just contain deftest and so on

Margo18:01:09

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


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

thheller18:01:10

nothing related to runner stuff. that is completely optional. I guess the docs should make that clearer.

Margo18:01:21

then i see blank page

thheller18:01:23

remove start/stop/init completely

Margo18:01:41

It says I should do that in the docs

thheller18:01:52

and do NOT specify a :runner-ns in your build config

Margo18:01:19

hmm, I can try it

thheller18:01:26

yeah I'll clear that up. :runner-ns (optional)

thheller18:01:31

this is definitely not clear enough 😛

Margo18:01:53

after deleting :runner-ns I see nothing

thheller18:01:56

ok now you likely need to delete the index.html you created

thheller18:01:03

shadow-cljs will generate a new one (when you start the watch)

Margo18:01:27

Same here

thheller18:01:21

{...
 :builds
 {:test
  {:target :browser-test
   :test-dir "test-out"
   :ns-regexp "-test$"
   :devtools {:http-port 8021
              :http-root "test-out"}}}}

thheller18:01:47

try this. just in case there are files or whatever in the old :test-dir interfering with stuff

thheller18:01:40

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

thheller16:01:41

@i did you restart after adding the dependency?

pinkfrog16:01:01

Yes. Now I manually add the dependency.