Fork me on GitHub
#shadow-cljs
<
2021-10-10
>
Adam Helins17:10:53

When async tests fail, testing messages are not printed. Is that expected, is there any solution? Unsure whether it is about shadow or CLJS itself.

borkdude17:10:33

it seems the testing stuff is done in a try/finally which kind of assumes sync testing probably

thheller17:10:22

no clue. if you setup an example showing it working with regular CLJS I will investigate 😛

borkdude17:10:26

instead it could maybe done using the test blocks thing with functions that are picked up from the queue

thheller17:10:32

don't think I ever used testing once 😛

pesterhazy17:10:07

Cljs.test generally has poor support for async

pesterhazy17:10:00

Which is unfortunate, given that almost everything interesting in JS is asynchronous

Adam Helins17:10:42

Oh yeah, it seems to be implemented in a try-catch so it wouldn't work in an async setup. Which is a tad weird since async examples do use testing: https://clojurescript.org/tools/testing

Adam Helins17:10:09

That's why I thought there might be something off with Shadow's test runner

pesterhazy17:10:06

FWIW this is one reason why I'm switching to Jest (cljs.test has a weak design and is effectively maintained)

pesterhazy17:10:23

I added selective test running once to cljs.test and it required monkey patching

thheller17:10:04

that really has little to do with cljs.test. :node-test can do selective test runs just fine

thheller17:10:21

been meaning to implement it for :browser-test just never got around to it

thheller17:10:35

cljs.test isn't great overall I'd agree on that but the basics are fine. All the macros really are the problem

thheller17:10:51

shadow.test fixes that and beyond that there is just some UI that needs to be written to get the fancy stuff

pesterhazy17:10:36

Yes we're using shadow.test for that now, much better than my macguyver solution

borkdude18:10:02

I think the testing stuff can be made to work with async tests

borkdude18:10:46

someone needs to make an issue about it, probably after chatting in #cljs-dev

thheller18:10:14

first actually verify. it might absolutely be shadow

borkdude20:10:16

ok, I can see from the code already that this isn't going to work async, but here is a repro:

$ plk
ClojureScript 1.10.597
cljs.user=> (require '[clojure.test :as t])
nil
cljs.user=> (t/deftest foobar (t/async done (t/testing "dude" (js/setTimeout (fn [] (t/is (= 3 4)) (done)) 1000))))
#'cljs.user/foobar
cljs.user=> (foobar)
1

FAIL in (foobar) (:)
expected: (= 3 4)
  actual: (not (= 3 4))
cljs.user=> (t/deftest foobar (t/testing "dude" (t/is (= 3 4))))
#'cljs.user/foobar
cljs.user=> (foobar)

FAIL in (foobar) (file:44:173)
dude
expected: (= 3 4)
  actual: (not (= 3 4))

borkdude20:10:57

the try/finally just isn't going to work with async, the finally block is of course executed too early

Adam Helins20:10:38

Yep, same conclusion!

borkdude07:10:22

What you can of course do is move the testing into the callback, but then it won't nest properly

sheluchin17:10:54

When using the Inspect Stream window, is there a way to get the path to the current object within its context?

thheller19:10:36

@alex.sheluchin no, not that simple. it'll use datafy/nav so constructing a "path" may not always be that reliable. also the UI navigates by index so it never knows actual path values

sheluchin20:10:34

Thanks @U05224H0W. Not so complicated to figure out the path manually. Was just wondering if there was a shortcut.

rafaeldelboni20:10:08

Hey I tried to bump to version 2.15.11 from 2.15.10 and my project and tests started to throwing this https://github.com/rafaeldelboni/stasis/runs/3852914797?check_suite_focus=true:

Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$lib$react_markdown'

Chrome Headless 94.0.4606.0 (Linux x86_64) WARN: 'shadow-cljs - failed to load', 'module$node_modules$react_markdown$index'

Chrome Headless 94.0.4606.0 (Linux x86_64) ERROR
  Uncaught ReferenceError: babelHelpers is not defined
  at ci.js:116796:9
  
  ReferenceError: babelHelpers is not defined
      at Object.shadow$provide.module$node_modules$react_markdown$lib$react_markdown (ci.js:188082:442)
      at shadow.js.jsRequire (ci.js:116793:18)
      at Object.shadow$provide.module$node_modules$react_markdown$index (ci.js:188088:300)
      at Object.shadow.js.jsRequire (ci.js:116793:18)
      at Object.shadow.js.require (ci.js:116818:20)
      at ci.js:188249:56 
Is there anything new I need to do in the new version? This only happens after I bump to the new version and delete the folder .shadow-cljs

thheller21:10:41

@rafaeldelboni oops, should be fixed in 2.15.12. there was some compiled code from a branch in that release that shouldn't have been.

rafaeldelboni21:10:49

Thanks for your fast reply! :)

pesterhazy21:10:04

continuous delivery ftw!

Chris McCormick23:10:01

Is deps.edn the only way to pull in a dependency from a git repository when using shadow-cljs at the moment? Or is there a way to specify git deps in shadow-cljs.edn?

Ryan Jerue01:10:15

If you're on lein, there's https://github.com/reifyhealth/lein-git-down I also don't think there's anything stopping sometime from putting it in a package json and adding it to to your paths. Not very elegant, but could work.