hi! is there a best practice on how to write tests for functions used in a react native environment? i tried targeting :node-test and :karma but β i guess one could have expected that β they throw syntax errors because i include react native modules written in / with flow for the type checks done in that module. as a disclaimer, iβm still in the early phases of clojure(script) development and also react native, so i guess i took on quite a challenge combining both from the start. π iβd say my ideal scenario would be to test all my pure functions within the clojurescript side of things and i also think thatβs the way to go. iβm not really after testing my ui modules / interactions. however, even with a minimal example for a test namespace that doesnβt include any of the namespaces using react native stuff i still get that syntax error, so iβm kinda out of ideas right now. maybe my only choice is to run my tests at runtime in the replβ¦?
@moledur best ask in #cljsrn I don't do react-native development myself and don't have a clue about testing π
okay thanks π
Hi there. I'm having some problems with importing JS file inside CLJS file. Specifically, when using the normal (:require ["blah" :refer [blah]])
I'm getting this error TypeError: $jscomp.inherits is not a function
. I'm currently using [org.clojure/clojurescript "1.10.773"]
and [thheller/shadow-cljs "2.11.11"]
. Has anyone seen anything like this and can point me to the right direction? Thanks.
I have the same issue actually. Last time it was removed by bumping compiler support from default to :es5 then bumping again to :es6. But now, even on :es6 it has appeared π. IIRC this is an issue with polyfills
So I "solved" it by bumping to es6
, but right now I have the exact opposite problem where I can't reproduce the problem even if I put it back to default. Everything else stays the same afaict.
I created a small pet project to try to reproduce the problem so @thheller can have a look at it. In the end I couldn't reproduce the error with the exact same configs and everything :mind_blown:
Yup. It's weird. I've had the issue several times. Never ever has it occurred on my local machine - only ever with my GH action build server. It's very, very random - I think the issue only randomly appears depending on some very pesudo-random build state inside of shadow.
Chaos engineering gone wrong π
please post any thoughts you have on the subject there π
Will do thanks
Update: Setting the compiler feature set to es6 makes it work. I guess es5 is not an option.
@rextruong unfortunately I haven't been able to reproduce this issue. es5 is the default and should be an option but breaks on some code. I don't know why, would help if you can make a reproducible repo
Sorry unfortunately I can't reproduce this anymore by some magical reasons π
good morning! I'm trying to use the expound
library to pretty-print spec failures. Here's how expound
is supposed to work in cljs:
$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.773"} expound {:mvn/version "0.8.7"}}}' -M -m cljs.main -re node
ClojureScript 1.10.773
cljs.user=> (require '[clojure.spec.test.alpha :as stest])
nil
cljs.user=> (require '[clojure.spec.alpha :as s])
nil
cljs.user=> (require '[expound.alpha :as expound])
nil
cljs.user=> (defn add1 [x] (+ 1 x))
#'cljs.user/add1
cljs.user=> (s/fdef add1 :args number?)
cljs.user/add1
cljs.user=> (stest/instrument `add1)
[cljs.user/add1]
cljs.user=> (set! s/*explain-out* expound/printer)
#object[expound$alpha$printer]
cljs.user=> (add1 nil)
Execution error - invalid arguments to cljs.user/add1 at (<cljs repl>:1).
<filename missing>:<line number missing>
-- Spec failed --------------------
Function arguments
(nil)
should satisfy
number?
-------------------------
Detected 1 error
However, when I do this in a repl controlled by shadow (both in CIDER and in the command line) I get instead some raw error object:
#error {:message "Call to #'cljs.user/add1 did not conform to spec.", :data {:cljs.spec.alpha/problems [{:path [], :pred cljs.core/number?, :val (nil), :via [], :in []}], :cljs.spec.alpha/spec #object[cljs.spec.alpha.t_cljs$spec$alpha30168], :cljs.spec.alpha/value (nil), :cljs.spec.alpha/fn cljs.user/add1, :cljs.spec.alpha/args (nil), :cljs.spec.alpha/failure :instrument}}
Is there a way to control how a failing spec is printed out in shadow-cljs
?I'll make an issue soon π
I have run into an odd issue trying to require a library (@emotion/styled) from npm, where the library works fine on its own, but fails to be required after adding an unrelated npm dependency (@storybook/react). I created a reproduction here: https://github.com/dvingo/shadow-cljs-requires-bug Based on the output from the shadow-cljs build screen ("Babel transform:" statements) I suspect that there is some babel transformation happening to @emotion/styled via a transitive dependency of @storybook/react, but I haven't been able to figure out what it is. I played around with js-options for @emotion/styled to try and force a certain file to be used, but nothing has worked.
@thheller done at https://github.com/thheller/shadow-cljs/issues/825
thx
@thheller hey I am trying to work on a better Kaocha hook to start a shadow build if it isn't already running. Currently the hook, running in clj, is using
(shadow-api/release (:shadow/build testable))
but this kinda crappy side effect of always starting a new shadow server even if one is running. Is there an easy way to mimic what the shadow-cljs
npm package does when starting a build by connecting to a running server or starting a new one?I guess I could always just shell out to start the build but I would prefer use a proper shadow api if possible
I'm getting a build error caused by an npm dependency issue
[:app] Build failure:
Failed to inspect file
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js
it was required from
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/geometry/projection.js
Errors encountered while trying to parse file
/mnt/c/Users/ghvw/projects/clojure/skedaddle/node_modules/@arcgis/core/chunks/pe.js
{:line 5, :column 231, :message "'}' expected"}
Does this look familiar to anyone?
I'm new to both clojurescript and shadow-cljs and so I thought I'd ask if this might be caused by something a newbie like me would do that is obvious to veteran users.
if it's of any use, characters 220-240 of the pe.js file looks like this "t(((e,t)=>{import("./"
, so it looks like it doesn't like something somewhere right at the {
and import
. Anyone have any ideas what I might be doing wrong?
I should mention the npm package is a beta package, its possible there's something wrong, I just doubt its them.has anyone ever run into an erroneous no output for id
error while using the repl?