shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
victorb 2020-10-23T09:59:41.089800Z

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

thheller 2020-10-23T10:15:09.090600Z

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

thheller 2020-10-23T10:15:18.090800Z

its not shadow-cljs doing this

victorb 2020-10-23T10:18:52.092Z

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

frankitox 2020-10-23T13:29:23.097800Z

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

frankitox 2020-10-23T13:29:28.097900Z

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.

thheller 2020-10-23T13:44:15.098400Z

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

thheller 2020-10-23T13:44:50.098600Z

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

thheller 2020-10-23T13:46:03.098800Z

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

thheller 2020-10-23T13:46:16.099Z

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

frankitox 2020-10-23T14:45:10.099200Z

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.

frankitox 2020-10-23T14:45:19.099400Z

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"}' .

👍 1