I have some scala.js unit tests written in utest. They all run just fine from the sbt build, however I would like to be able to step through the unit tests in a debugger. Using my favorite IDE (intellij) to debug the tests won't work because it will try to run them on the JVM. Is there some way to step through the unit test execution similar to how you can step through the (javascript) application code in browsers like chrome?
Asked
Active
Viewed 1,278 times
1 Answers
11
Currently, the only way to (step-by-step) debug Scala.js code I know of, is inside a browser. You can generate an HTML runner for your tests in sbt:
sbt> testHtmlFastOpt
// snip
[info] Wrote HTML test runner. Point your browser to .../test-suite-fastopt-test.html
This works starting Scala.js 0.6.10.

gzm0
- 14,752
- 1
- 36
- 64
-
gzm0: It seems that later versions sbt-scalajs plugin do not generate (projectname)-test-fastopt.js nor (projectname)-test-jsdeps.js. during test command any more. Version 0.6.5 did but 0.6.7, 0.6.8. do not. Is it possible to generate these files by some sbt commands manually? – user4955663 Apr 01 '16 at 06:55
-
Yes, use `test:fastOptJS` / `test:fullOptJS`. – gzm0 Apr 01 '16 at 08:54
-
2Note that @gzm0's comment is obsolete; the question has been edited with a modern answer. – James Moore May 17 '17 at 02:31
-
1And even more modern answer is now `testHtml` (since [Scala.js 1.0.0](https://www.scala-js.org/news/2017/11/29/announcing-scalajs-1.0.0-M2/)) – Suma Nov 12 '20 at 09:43