Fork me on GitHub
#shadow-cljs
<
2018-05-08
>
heyarne09:05:21

are there any best practices on testing a re-frame app with shadow-cljs? i use emacs and cider for development, and i love cider-test-run-all-tests and cider-test-run-ns-tests. i guess i don't get this kind of emacs integration with shadow-cljs easily, right?

thheller09:05:19

I don't know? you should?

thheller09:05:47

does it work for clojurescript in general?

thheller09:05:06

might be clojure only?

thheller09:05:47

yeah the cider-nrepl middleware for this directly interfaces with clojure.test. no support for CLJS in general

heyarne09:05:03

yes, i noticed that too. i think i'll just go for continuous node-tests for now. i think i could still later on switch to using cljc tests

thheller10:05:39

if you have a REPL running you can just invoke tests from there

thheller10:05:41

rlwrap shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn version: 2.3.19
shadow-cljs - connected to server
[:node-repl] Configuring build.
[:node-repl] Compiling ...
[:node-repl] Build completed. (39 files, 19 compiled, 0 warnings, 7.92s)
[1:1]~cljs.user=> JS runtime connected.
[1:1]~cljs.user=> (require '[cljs.test :refer (deftest is)])
nil
[1:1]~cljs.user=> (deftest foo-test (is (= 1 2)))
{:namespaces {cljs.user {:vars {foo-test #'cljs.user/foo-test}}}, :hooked true}
[1:1]~cljs.user=> (foo-test)

FAIL in (foo-test) (at C:476:9)
expected: (= 1 2)
  actual: (not (= 1 2))
nil
[1:1]~cljs.user=>

thheller10:05:05

doesn't have all the fancy formatting but serves its purpose

jmckitrick13:05:39

@thheller Does 2.3.20 have the updated filter for less files?

jmckitrick13:05:37

👍:skin-tone-2:

jmckitrick16:05:05

I’ve added a project called tubax to my edn file, and when the page refreshes that has the dependency, I see this: The required namespace "ext.saxjs" is not available, it was required by "tubax/core.cljs".

jmckitrick16:05:44

I’m not sure if tubax is broken, or if I’m not configuring shadow to import it correctly.

jmckitrick16:05:04

So it looks like tubax has an assets/deps.cljs file

jmckitrick16:05:23

and it bundles sax.js with it

fatihict16:05:38

Can anyone help me with understanding of the :default key in shadow cljs requires? These are my requires:

["react" :refer [createFactory]]
["@atlaskit/field-radio-group" :default radio-group]
Here I create a factory and use the component:
(def radio-group (createFactory radio-group))
(radio-group #js {...})
I assumed the call to radio-group here would result in a call to the factory and not the class radio group. Is this a wrong assumption? If I change my require from ["@atlaskit/field-radio-group" :default radio-group] to ["@atlaskit/field-radio-group" :as radio-group] and my def from (def radio-group (createFactory radio-group)) to (def radio-group (createFactory radio-group/default)) my code does work.

justinlee17:05:31

@fatihict i do essentially the same thing with react-flip-move but I use reagent’s adapt-react-class instead of createFactory and it works

justinlee17:05:01

but given that you get it work work with the alternate syntax I wonder if there is something messed up with the default import

thheller17:05:16

@fatihict :default is tricky since it depends on whether the npm lib was packages as commonjs or es6

thheller17:05:46

@jmckitrick funcool has a lot of these ... :foreign-libs are not supported. it appears to be this package https://www.npmjs.com/package/sax

thheller17:05:20

so npm install sax and then create a (ns ext.saxjs (:require ["sax" :as sax])) (js/goog.exportSymbol "sax" sax")

jmckitrick17:05:42

While I’m thinking about it, the react-select component works great, but the X icon for removing a ‘chip’ from the multi-select mode is rendering as a ~A or something like that. It’s supposed to me &times;. Would that have anything to do with shadow?

thheller17:05:15

more likely to the encoding of your page

thheller17:05:51

try <meta charset="UTF-8"> in your <head>

thheller17:05:33

assuming you are using utf-8 or course 😉

jmckitrick17:05:48

I was UTF-8 before UTF-8 was cool, lol.

jmckitrick17:05:58

Actually, this is from the cloned quickstart…

jmckitrick17:05:04

So I might open a PR for this

thheller17:05:18

well did it fix that?

jmckitrick17:05:24

Boom. Problem solved.

thheller17:05:36

hmm strange

jmckitrick17:05:40

I should have thought of that, but it’s something I so rarely deal with….

jmckitrick17:05:18

I forgot the simple stuff, too. Was thinking of minification, etc.

fatihict17:05:03

Ah, good to know. Thanks @thheller & @lee.justin.m

thheller17:05:51

@jmckitrick are you using the proxy support? that might be the problem. the dev server usually sets charset=utf-8 via http headers

jmckitrick17:05:00

Hmm. Let me see…

thheller17:05:04

so setting it in html should usually not be required

jmckitrick17:05:24

Yes, let me restart without and see…

thheller17:05:40

no need to restart

thheller17:05:50

just comment out the proxy url and save the config

thheller17:05:02

it'll restart the http server

jmckitrick17:05:00

Actually, that did not solve it. But the meta tag did.

thheller17:05:43

feel free to open a ticket for this. I'll see if I can reproduce this later.