kaocha-cljs icon indicating copy to clipboard operation
kaocha-cljs copied to clipboard

Add support for source maps

Open eerohele opened this issue 5 years ago • 5 comments

Currently, if a test throws an exception, every line of the stack trace refers to a .js file. It would be more useful if stack traces referred to the original ClojureScript files instead.

eerohele avatar Mar 12 '20 11:03 eerohele

I think this is a consequence of our use of the REPL to execute code, but I'm not sure. There may not be any sort of out of the box solution and we may have to manually "fix" the stack traces using the source map to point to the actual source.

alysbrooks avatar Oct 29 '22 01:10 alysbrooks

Tried to run the shadow-browser example in here with the config that enable source map, and found that with shadow-cljs.edn like below, and I can see the exception with correct cljs line number in browser's console.

{:source-paths ["src" "test"]
 :dependencies []

 :dev-http {8000 "out"}

 :builds
 {:main
  {:target :browser
   :modules {:main {:entries [basic-shadow.main]}}}

  :test
  {:optimizations :none
   :source-map true
   :target :browser-test
   :test-dir "out"}}}

humorless avatar Mar 21 '23 13:03 humorless

That's using shadow's test runner, not kaocha.

plexus avatar Mar 22 '23 16:03 plexus

I did a little bit more research on this topic, and I found a npm library seems related. source-map-support

humorless avatar May 19 '23 10:05 humorless

Adding as a "feature request" but marking as a low priority since shadow test runner provides a workaround for a user who wants a .cljs stack trace.

lambduhh avatar Mar 27 '24 06:03 lambduhh