Fork me on GitHub

If I want to compile some tests for puppeteer or similar, to be ran both with watch and a single test with return 0 if tests pass, which build target is the best? After 2 days of trying everything and nothing working out, I am inclined to believe that I should either use jvm (i.e. etaoin) or none of the -test builds, but node-script. Is this correct?


@ashnur node-test should be fine


thanks, I will try that again then : )


One thing I am really confused about is that it seems the process exists before the go blocks finish running.


well you need to use the async test helper. otherwise the tests finish without waiting for async stuff and exit the process.


Ok, that sounds reasonable but I am looking here and I am not really sure what would be the 'helper' that you refer to. The whole page doesn't have this word on it : )


because its not shadow-cljs related. it is cljs.test/async


sorry, this is embarrassing. thanks again

Samuel McHugh11:08:09

Hello, I'm trying to get a test build working with devcards test. My working devcards build has a option

:build-options {:ns-aliases {devcards-marked cljsjs.marked, devcards-syntax-highlighter cljsjs.highlight}}
specified. The problem is that this :build-options key is not available when setting up a :test build. So any files in devcards which match the -test$ regex will try to compile with this test build, but they will also end up including devcard.core leading to the marked issue.


@smchugh230395 I'm not sure what you mean by :build-options key is not available ...

Samuel McHugh11:08:01

  {:target    :node-test
   :output-to "out/node-tests.js"
   :ns-regexp "-spec$"
   :autorun   true
   :main      optional}}}
This is the list of config options according to the docs. It does not list :build-options as a valid config option. I thought maybe it is valid, but unlisted in the docs, so I tried including it in the test config options. This did not solve the issue though as opposed to my :mycards build which works fine.


:build-options can be used in any build, the docs just don't mention it. just like :compiler-options and :js-options.

Samuel McHugh11:08:48

That was indeed my suspicion. When I ran previously I was still getting the same issues with regards to "devcards-marked" but now it's compiling. I must have made an error when compiling. Sorry about that. Thanks for the help.

jeff tang20:08:03

Hello, I'm currently building a cljs electron app. I'm finding some difficulty accessing node.js APIs from renderer application namespaces. For instance, I can access fs fine from main, but not from the application code. I can access npm modules fine from the application as well, such as @material-ui/icons. Most of my code is based off of, and I have enabled nodeIntegration.

jeff tang21:08:26

Interestingly, when I add (:require ["electron" :as elec :refer [ipcRenderer]]) to the top of a renderer file, and print elec, it is an empty js object.

jeff tang21:08:57

Verified: from the electron console, module$node_modules$electron$index returns an empty object

jeff tang21:08:23

Whoo. I'm able to (js/require "fs") . I need to understand the difference between :require and js/require ...

jeff tang21:08:18

Appears that js/require is commonJS require('') whereas :require is fancy ES6 import * from ""

jeff tang21:08:19

I wonder if this has something to do with :target :browser for the renderer code. Perhaps shadow-cljs doesn't expect this code to also have node.js access in the case of electron?

Pavel Klavík21:08:09

@thheller So the strange error with incorrect UTF-8 start byte started occuring to me again:

Pavel Klavík21:08:09

Exception in thread "XNIO-1 I/O-3" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8
 at [Source: [email protected]; line: 1, column: 92]
        at com.cognitect.transit.impl.ReaderFactory$
        at cognitect.transit$read.invokeStatic(transit.clj:319)
        at cognitect.transit$read.invoke(transit.clj:315)
        at shadow.cljs.devtools.server.common$fn__14808$fn__14809.invoke(common.clj:47)
        at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
        at clojure.core.async.impl.channels$chan$fn__872.invoke(channels.clj:300)
        at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj:83)
        at clojure.core.async$put_BANG_.invokeStatic(async.clj:199)
        at clojure.core.async$put_BANG_.invoke(async.clj:187)
        at shadow.undertow$fn$reify__16240$handler_fn__16241.invoke(undertow.clj:314)
        at shadow.undertow.WsTextReceiver.onFullTextMessage(
        at io.undertow.websockets.core.AbstractReceiveListener$2.complete(
        at io.undertow.websockets.core.AbstractReceiveListener$2.complete(
        at io.undertow.websockets.core.AbstractReceiveListener.readBufferedText(
        at io.undertow.websockets.core.AbstractReceiveListener.bufferFullMessage(
        at io.undertow.websockets.core.AbstractReceiveListener.onText(
        at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(
        at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(
        at org.xnio.ChannelListeners.invokeChannelListener(
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(
        at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(
        at org.xnio.ChannelListeners.invokeChannelListener(
        at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(
        at org.xnio.nio.NioSocketConduit.handleReady(
Caused by: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8
 at [Source: [email protected]; line: 1, column: 92]
        at com.fasterxml.jackson.core.JsonParser._constructError(
        at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidInitial(
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidChar(
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(
        at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(
        at com.cognitect.transit.impl.JsonParser.parseVal(
        at com.cognitect.transit.impl.JsonParser.parseMap(
        at com.cognitect.transit.impl.JsonParser.parseArray(
        at com.cognitect.transit.impl.JsonParser.parseVal(
        at com.cognitect.transit.impl.JsonParser.parse(
        at com.cognitect.transit.impl.ReaderFactory$
        ... 25 more

Pavel Klavík21:08:09

So I was digging little bit through my data and I found that the problem is with using non-ascii characters in strings. Evaluating the following form in REPL will throw the error:

Was something changed recently in using transit in Shadow-cljs? My version is 10.18.


@pavel.klavik works fine for me

s$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> "Křápová"


@tangj1122 :browser by default will try to bundle all js requires which isn't what you want in case of electron. so you can either set :js-options {:js-provider :require} or :js-options {:keep-as-require #{"fs" ...}}


:require will make everything go through require (so via nodeIntegration). :keep-as-require lets you select whichever packages but defaults to bundling all others

Pavel Klavík22:08:15

so it works with node-repl

Pavel Klavík22:08:05

and I tested everything from scretch and I get the same error with this output in REPL:

Connecting to remote nREPL server...
Clojure 1.10.1
=> "Křápová"
(shadow/repl :client)
To quit, type: :cljs/quit
=> [:selected :client]


don't know what to tell you. works fine in node-repl and browser-repl for me.


maybe your browser encoding is messed up?


also works fine over nrepl

(shadow/repl :browser)
To quit, type: :cljs/quit
=> [:selected :browser]
=> "Křápová"

Pavel Klavík23:08:39

no idea, but it is broken in both firefox and chrome

Pavel Klavík23:08:15

maybe something in my shadow-cljs.edn?

{:source-paths ["src"]
 :dependencies [[reagent "0.10.0"]
                [reagent-utils "0.3.3"]
                [re-frame "0.12.0"]
                [com.cognitect/transit-cljs "0.8.264"]
                [ "v0.2.0"]
                [hickory "0.7.1"]
                [binaryage/devtools "0.9.10"]
                [bidi "2.1.6"]
                [com.taoensso/sente "1.15.0"]
                [venantius/accountant "0.2.5"]
                [com.cemerick/url "0.1.2-SNAPSHOT"]
                [com.taoensso/timbre "4.10.0"]
                [ "0.1.8"]
                [bouncer "1.0.1"]
                [orgpad/volcano "0.1.2"]
                [macchiato/core "0.2.17"]
                [macchiato/env "0.0.6"]
                [mount "0.1.16"]]
 :nrepl        {:port 9000}
 :builds       {:client     {:target           :browser
                             :output-dir       "resources/public/js/compiled"
                             :asset-path       "/js/compiled"
                             :modules          {:shared {:entries []}
                                                :main   {:init-fn    orgpad.client.core/init
                                                         :depends-on #{:shared}}
                                                :layout {:entries    [orgpad.client.layout.webworker.core]
                                                         :depends-on #{:shared}
                                                         :web-worker true}}
                             :compiler-options {:infer-externs      :auto
                                                :output-feature-set :es6}
                             :devtools         {:after-load     orgpad.client.core/mount-root
                                                :before-load    orgpad.client.core/stop-web-workers
                                                :watch-dir      "resources/public"
                                                :browser-inject :main
                                                :loader-mode    :script}}
                :landing    {:target     :browser
                             :output-dir "landing/resources/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn}}
                             :devtools   {:http-root      "landing/resources"
                                          :http-port      3500
                                          :watch-dir      "landing/resources"
                                          :browser-inject :main}}
                :emails     {:target     :browser
                             :output-dir "emails/js"
                             :asset-path "/js"
                             :modules    {:main {:init-fn}}
                             :devtools   {:http-root      "emails"
                                          :http-port      3600
                                          :watch-dir      "emails"
                                          :browser-inject :main}}
                :screenshot {:target           :node-script
                             :main             orgpad.screenshot.core/main
                             :output-to        "screenshot/screenshot.js"
                             :devtools         {:autoload true}
                             :compiler-options {:optimizations :simple}}}}

Pavel Klavík23:08:22

it fails in client project


can't think of anything that would affect this in shadow-cljs. maybe a bad charset encoding in your editor/terminal? should be utf-8

Pavel Klavík23:08:40

I am using Cursive nREPL

Pavel Klavík23:08:03

how can I access REPL from terminal?


try <meta charset="utf-8"> if its not in your HTML. wouldn't be the first time this fixed something.


shadow-cljs cljs-repl client or just shadow-cljs node-repl or browser-repl

Pavel Klavík23:08:20

it works fine from cljs-repl from terminal


maybe weird encoding in cursive then? I don't have a clue, the nrepl I tested was also in cursive.

Pavel Klavík23:08:27

I have this in my HTML:

<meta charset='utf-8'>

Pavel Klavík23:08:45

I will try to update Cursive to see whether it won't fix it