Fork me on GitHub
#shadow-cljs
<
2020-10-23
>
victorb09:10:41

Trying to setup some very basic tests via shadow-cljs, but getting Uncaught ReferenceError: tests is not defined on the runner page. My target:

{:target :browser-test
   :test-dir "resources/public/js/test"
   :devtools {:http-port 8021
              :http-root "resources/public/js/test"}}
My test file (in components/searchbar-test.cljs)
(ns components.searchbar-test
  (:require [cljs.test :refer (deftest is)]))

(deftest a-failing-test
  (is (= 1 2)))
Test file is right next to the implementation file, and it's correctly added to the classpath AFAIK (`:source-paths ["src/main"]` defined in shadow-cljs config) Running the tests with npx shadow-cljs watch test

thheller10:10:09

my guess is that you have custom index.html in resources/public/js/test that calls tests.something in a script?

thheller10:10:18

its not shadow-cljs doing this

victorb10:10:52

Hm, not as far as I know, all I did was the target+test file above. Seems something went wrong while I was first setting it up, removing resources/public/js/test and restarting the watcher for the tests solved the problem. Thanks once again

frankitox13:10:23

Alright, someone here trying the WSL2 + react-native combo? Or at least only WSL2?

frankitox13:10:28

I can't shadow-cljs to connect to my device (getting websocket connection error through port 9630). I've been following this https://gist.github.com/bergmannjg/461958db03c6ae41a66d264ae6504ade which tells you to forward port 8081 from Windows to WSL (for the Metro server), so I tried to do the same for port 9630 without luck. Is there any other port I should forward? Is there any way to use other protocol instead of websockets? Although there's the possibility this is a WSL2 bug, I found a related message in https://clojurians-log.clojureverse.org/shadow-cljs/2020-01-27.

thheller13:10:15

I don't have a clue about the react-native bits but if you have shadow-cljs running in WSL2 then the port it is using must be reachable by your mobile

thheller13:10:50

its only port 9630 (or 9631++ if those are used)

thheller13:10:03

usually a good first step is just opening the browser on the mobile and trying to access the website on 9630

thheller13:10:16

once you have that going and working getting it to work in your app should be straightforward

frankitox14:10:10

Thank you!! The suggestion to open the browser on mobile really helped me. The problem was that the shadow-cljs server and the phone live in different subnets.

frankitox14:10:19

The subnet for Win + WSL2 is 172.17.134.96/28 , Win using 172.17.134.97 and WSL2 using 172.17.134.106. The subnet for Win + phone is 192.168.0.0/24, Win using 192.168.0.193 and the phone 192.168.0.133. So to solve it I had to: 1. Forward 192.168.0.193:9630 -> 172.17.134.106:9630 (Powershell's command netsh interface portproxy add v4tov4 listenport=9630 listenaddress=192.168.0.193 connectport=9630 connectaddress=172.17.134.106). 2. Run shadow-cljs with --config-merge '{:local-ip "192.168.0.193"}' .

👍 3