Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug scala.js unit tests?

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?

like image 612
Julie Avatar asked Jun 10 '15 03:06

Julie


People also ask

How do I debug a test in IntelliJ?

If you don't know why a test fails, you can debug it. In the editor, click the gutter on the line where you want to set a breakpoint. There are different types of breakpoints that you can use depending on where you want to suspend the program. For more information, refer to Breakpoints.

How do I open Scala REPL in IntelliJ?

Click the "Run Pants REPL" button in the top toolbar to start the REPL. This will create a configuration for the current target, compiles it, and then start the REPL. If IntelliJ has the target indexed, code completion will be available in the REPL.


1 Answers

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.

like image 165
gzm0 Avatar answered Nov 15 '22 09:11

gzm0