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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With