debugging,intellij-idea,scala.js,utest , How can I debug scala.js unit tests?


How can I debug scala.js unit tests?

Question:

Tag: debugging,intellij-idea,scala.js,utest

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?


Answer:

Currently, the only way to (step-by-step) debug Scala.js code I know of, is inside a browser. The Scala.js sbt plugin does currently not easily allow you to export a JS file you can load in the browser and run.

However, if you really need to, you can do so manually:

import org.scalajs.testinterface.ScalaJSClassLoader
import sbt.testing._

object TestRunner extends js.JSApp {

  // The tests you want to run
  val testNames = Array(
    "com.package.YourTest",
    "com.package.YourTest2"
  )

  // The test framework you use. Same as sbt's
  // testFrameworks += new TestFramework("utest.runner.Framework")
  val framework = new utest.runner.Framework

  // Arguments to the test framework
  val args = Array[String]()

  def main(): Unit = {
    val loader = new ScalaJSClassLoader(js.Dynamic.global)

    val runner = framework.runner(args, args, loader)

    // The test tasks you want to run
    val taskDefs = for {
      testName <- testNames
    } yield {
      new TaskDef(testName, framework.fingerprints.head, true, Array())
    }

    runTasks(runner.tasks(taskDefs))
  }

  private def runTasks(tasks: Array[Task]) = {
    tasks.foreach(_.execute(DummyEventHandler, ConsoleLogger, runTasks))
  }

  object ConsoleLogger extends Logger {
    def ansiCodesSupported(): Boolean = false
    def error(msg: String): Unit = println(msg)
    def warn(msg: String): Unit = println(msg)
    def info(msg: String): Unit = println(msg)
    def debug(msg: String): Unit = println(msg)
    def trace(t: Throwable): Unit = t.printStackTrace()
  }

  object DummyEventHandler extends EventHandler {
    def handle(event: Event): Unit = ()
  }
}

When you call TestRunner.main(), this should run the tests you specified. You can then set breakpoints in your browser and step-by-step debug.

Feel free to report an issue on GitHub, if you need this often and would like it to be better streamlined. Reported as #1709


Related:


Eclipse Debugger Hitting Comments, Skipping Actual Code


eclipse,debugging
Using Eclipse Luna Service Release 2 (4.4.2) Build id: 20150219-0600 Java Web app running in Tomcat v8.0 (Gold Copy) I've restarted my Eclipse and its debugger numerous times over the course of several days, this has been happening constantly for a few days now, so this is not some random...

Intellij web application on tomcat server shows http://localhost:8080/index.jsp instead of http://localhost:8080/myapp/index.jsp


java,jsp,tomcat,servlets,intellij-idea
I'm following a tutorial on udemy. In the tutorial he is using eclipse. But i'm following the course with intellij. Every thing works fine but one thing i keep noticing is that when he runs the servlets or jsp pages it is always shows the project name before the servlet(http://localhost:8080/myapp/index.jsp)....

Print addresses of all local variables in C


debugging,pointers,gcc,gdb,memory-address
I want to print the addresses of all the local and global variables which are being used in a function, at different points of execution of a program and store them in a file. I am trying to use gdb for this same. The "info local" command prints the values...

What is this error about perllocale in Perldoc?


osx,perl,debugging,documentation,locale
I was discussing here about setting no locales in Perl and was recommended to run this perldoc perllocale in OSX Yosemite 10.10.3 but I get the error: Error while formatting with Pod::Perldoc::ToMan: at /System/Library/Perl/5.18/Pod/Perldoc.pm line 1346. at /usr/bin/perldoc5.18 line 11. Got a 0-length file from /System/Library/Perl/5.18/pods/perllocale.pod via Pod::Perldoc::ToMan!? at /usr/bin/perldoc5.18...

Perl Debugging Using Flags


perl,debugging,script-debugging
So my goal is to find an easy way to turn on print statements in Perl a flag. In C/C++ you can use a #define to choose if certain code is run and it is a way to turn on and off debug print statements. Where if a #define DEBUG...

Create a hyperlink to a project file in console output


java,intellij-idea,hyperlink,console,log4j
Is there a way for me to write out a link to the console output that when clicked on directs to a project file in Intellij? For example, this happens when a run-time exception occurs. I see the stack trace and I can click on a link in the console...

IntelliJ - use imported modules as dependencies like maven projects in Eclipse


eclipse,scala,maven,intellij-idea,sbt
I've been asking myself this question for a couple of years but never really found the solution. I used to work with eclipse (on maven java projects). I could import a project -let's call it 'proj-A'- and if one of proj-A's dependencies was found in the workspace with the same...

How to pass or declare array members in c?


c,arrays,debugging,parameter-passing
I developed a program that is supposed to pass the following members of the array of double purchase from the following function: float beverages () { char response; double purchase [8]= {3.50, 3.80, 3.90, 4.20, 4.00, 4.30, 3.00, 3.10}; printf("\nEnter your order: "); scanf("%c", response); if (response == 'l') {...

IntelliJ/Webstorm not finding import reference


javascript,intellij-idea,phpstorm,webstorm,ecmascript-6
I have the following project structure: root src scripts main.js foo.js Inside of my main.js file, I'm importing foo.js like so: import 'src/scripts/foo.js' When I click on the import statement above and go to Navigate -> Declaration I get a super helpful message that says Cannot find declaration to go....

Visualizing gradle dependencies in Intellij


intellij-idea,gradle,intellij-14
Is there a way to visualize project dependencies for a gradle project in Intellij? For a maven project, if you right click in the pom.xml you get a Show dependencies option but there I don't see such an option for a gradle project. Does this feature exist for gradle project?...

ESLint: How to set .eslintrc to recognize 'require'?


javascript,intellij-idea,jslint,lint,eslint
I am new to ESLint, and I have successfully integrated ESLint with IntelliJ. Out of the box, my integration of ESLint did not recognize node, but basic review of documentation made clear that by creating the configuration file named .eslintrc at the root of my project folder (with the proper...

Install Ultimate edition IntelliJ plugins in Android Studio


android,intellij-idea,android-studio
I have Ultimate edition of IntelliJ Idea w/ a valid licence. There is a very useful plugin only available in full edition named Database Tools and SQL support that allows the developer to browse and run queries on sqlite database stored in phone. Now i need to use this plugin...

Is it possible to highlight ObjC code in Intellij IDEA?


objective-c,intellij-idea,syntax-highlighting
Intellij IDEA have IDE AppCode for iOS projects on ObjC/Swift. I am develop crossplatform app (android and ios supports) on Cordova which contain Java, JS and ObjC as base languages. And unforunately IDEA do not highlight ObjC code. I have not found a plugin that would it did. Is it...

iOS how to programmatically read device's screen auto-lock timeout time?


ios,objective-c,debugging,screen-lock,user-inactivity
I'm creating a method to send debug info to the support team for one of my apps. I have method calls like these: NSString* appVersion = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]; NSString* build = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"];; NSString* iOSVersion = [[UIDevice currentDevice] systemVersion];; An additional requirement is to understand how our internal...

Why IDEA shows java files as invalid in my Android project?


java,android,intellij-idea
I am trying to build apk from this repository. I have problem: idea show .java files as invalid, you can see it on this pic: What am I doing? I download mentioned (git) sources and copy sources to some directory I open this directory from IDEA as directory In project...

Rails 4 + delayed job - constantly writing debug code to production logs


ruby-on-rails,debugging,delayed-job
I'm using delayed job for the first time, and it seems to be working fine. I started to tail my production log to fix another issue, and found that delayed job is constantly updating the production log with debug code. Is this normal, and can I turn it off? [2015-06-14T16:05:35.983383...

Errors trying to add rectangles to JPanel


java,swing,debugging,graphics
I am trying to draw a grid of rectangles on a JPanel that already has a few JButtons on it. I get a big list of errors when I try to run it. Here's my code: package GameOfLife; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.*;...

Codecademy “SyntaxError: Unexpected token else”


javascript,debugging
I'm doing the codecademy js course, and I'm at the part with rock paper scissors. When I save the code it says "SyntaxError: Unexpected token else". What did I do wrong? This is my code: var compare = function(choice1, choice2) { if (choice1 === choice2) { return("The result is a...

C++ Have lone executable log exceptions?


c++,debugging,exception,logging
I'm currently in a beta testing phase of my C++ Server. I'm sending it out to users to stress test it to see if an exceptions show up. However, since the .exe is a standalone, how do I make it so it automatically creates a dump or a log of...

BSTD inorder traversal produces erroneous behaviour


java,debugging,recursion,immutability
I have a BSTD implementation which is inserting values incorrectly and I can't find for the life of me what is going on. EXPECTED ACTUAL -------- ---------- Alex Janice Carlos Janice Elton Janice Janice Zidane Zidane Zidane Implementation private Node<K,E> insert(Node<K,E> node, K key, E elem) { if (node ==...

IntelliJ Plugin written in Scala - doesn't work


java,scala,intellij-idea,sbt,intellij-plugin
I want to develop my own IntelliJ plugin and I would like to do it using Scala language. When I use Java, everything work perfectly, but I'm not able to run a simple AnAction implemented in Scala. Have a look at these code samples, I have two AnAction implementations, one...

Why Intellij deletes obsolete files when trying to run DevMode?


java,gwt,intellij-idea
I'm currently working on a GWT project in my company. Although DevMode works perfectly fine in eclipse, I still want to use Intellij Ultimate Edition for development. But after all setups were done (Facet, Run/Debug configuration) I'm getting this weird processing window saying "Deleting Obsolete Files..." when I run the...

Add project on outer level as dependency to module


android,intellij-idea,gradle
I have a project that looks something like this: mainProject/ mainModule proj1/ module1 proj2/ module2 and what I'm trying to do is add proj1 and proj2 as dependencies to mainProject. I've gotten it to the point where I can import classes from the projects and everything seems to work fine...

Unexpected top level exception: bad class file magic, in Android


java,android,intellij-idea,ant
I am trying to compile my android program via command line, using ANT. And the code compiles fine. But when the target -dex is executed, I get the following error: [dex] input: /Users/aditya/Desktop/workspace/Java/Play/bin/classes [dex] input: /Library/Java/Android/tools/support/annotations.jar [dex] Using Pre-Dexed annotations-5bd0afe28d834ceff67df1063f0f145b.jar <- /Library/Java/Android/tools/support/annotations.jar [dex] Converting compiled files and external libraries into...

Debugging service test client: Netbeans debugger won't recognize Glassfish server


java,debugging,java-ee,netbeans,glassfish
Here's what I've done so far: Did a fresh build of project (web service project). Redeployed project war file to Glassfish server. Restarted server with --debug=true. Attached debugger from Netbeans. Debugger attaches to the server without an error (responds "User Program Running"), however the Debug tab (in the Projects/Files/Services window)...

Concurrent modification exception when using iterator? (Java)


java,debugging,arraylist,iterator
I am trying to write code for the simulation WaTor in which sharks and fish eat each other and simulate population control etc. Anyways, the problem I am having is that i keep getting a concurrect modification exception even when using an iterator. Here is my code: private void updateSharks()...

Outputing logs to Console in Android


android,debugging
I'm using the command line to build a project that I am working on: I use it to generate an APK, transfer it to my device, and then run it in on my device. I am trying to debug this application now, and I am not sure how to go...

spring boot switching from in-memory database to persistent database


intellij-idea,spring-boot,spring-data
I have developed my web-application using spring-boot and spring-data-jpa and and in-memory database, and I have a couple questions: how can i now switch to a persistent, let's say, MySQL database? What do I have to change in my configuration? Can spring-boot set a database up for me with a...

IntelliJ Sync Eclipse files - Where is this setting saved?


java,eclipse,intellij-idea,ide
In IntelliJ there is the option of linking IntelliJ-files with Eclipse-files. So that changes to dependencies make IntelliJ readjust .project-files and the other way around. This setting is chosen when importing the project into IntelliJ. Now, i wonder: Where is this setting saved and is it possible that i can...

Intellij isn't catching non-exhaustive matches that use functions as guards


scala,intellij-idea
I found this block of code in our codebase: val appId: (String, Option[String]) = request.app match { case Some(app) if hasAppId(app) => (Constants.AppId, app.id) case None => (Constants.AppId, None) } hasAppId returns a boolean. Clearly this match is non-exhaustive, but there's no compiler warning for it. If I change the...

Java Reflection vs Java Debug Interface (JDI) [closed]


java,debugging,reflection,jdi
What are the differences between use Java Reflection and Java Debug Interface? when can I use one and when the other?

What does the double colon mean in Scope Local variables in Chrome's debugger?


javascript,google-chrome,debugging
See the screen dump fragment below. Notice that there are two colons between legend and Object (legend is a field of ptd). What does the double colon mean? My problem is that if I test the value of ptd.legend, it is 'undefined'. Which it shouldn't be... ...

ASP.NET strange behaviour: Adding Debug=true in web.config changes css


css,asp.net,debugging,web-config
Just as the question states: When I add debug=true to my web.config (no other changes anywhere in the code) my page is rendered with no background colour. Any explanation why this should occur?...

AngularJS: UI-Router blank page debug


angularjs,debugging,angular-ui-router
I just wondering does anybody know how to debug situation when you have blank page for UI-Router. (Of course, without any errors in console) By doing console.log for router events(take from here) I found you that it went to correct state but after did not stop on breakpoint inside state...

iOS app crash on launch using XCode debugger, runs fine without debugger


ios,xcode,debugging,crash,launch
When running the app on a device (iphone), it crashes at startup without any error messages. But if the device is not connected to xcode (not in debug mode), just open up the app, it runs fine. Same code runs perfect on simulator. Never seen this before, I guess something...

Code styling without modifying the binaries


intellij-idea,webstorm,intellij-13,intellij-plugin
On the WebStorm for example and I believe in any Intellij product. You can easily refeactor the code and style it as you like from the setting 'Code Style'. But, the styling and refactoring actually change the binaries of the file. for example if you decide you want new line...

Java - duplicate case label


java,intellij-idea,switch-statement
I found some time ago a function to replace polish characters in text with "normal" version of this character. I used this in some projects earlier without problems, but now, when i just copied it, this doesn't want to work. But when I try to compile old projects in the...

How to convert Solaris MDB addresses into file names and line numbers?


debugging,solaris
Say you have a MDB stack trace that look like this: libumem.so.1`vmem_seg_alloc+0x170 libumem.so.1`vmem_xalloc+0x628 libumem.so.1`vmem_alloc+0x1f8 libumem.so.1`umem_alloc+0xec libumem.so.1`malloc+0x40 compute+0x14 main+0x54 _start+0x12c For example a stack trace that is generated when applying ::vmem_seg -v to an address that is listed by ::findleaks. The corresponding binary has debugging symbols included, thus it should be...

IntelliJ IDEA: Open test result tab only on failure


java,intellij-idea,ide
Can I setup IntelliJ to open the "Run" tab with the test results only if a unit test fails and keep it hidden otherwise?

Why main generation template is named psvm in IntelliJ?


intellij-idea,code-templates
According to help, main generation template is named psvm. Why didn't they name it just main?...

VBA Debugger shows only 256 elements of a collection


excel-vba,debugging,collections
the title explains my problem. Im working on an excelmakro and my questions is, is there an option that the debugger shows all elements like it does with an array? And if not, is the only workaround the storage of my classobjects in an array after inflating the collection? I...

Intellij JAVA_HOME variable


java,intellij-idea
I started using Gradle and Intellij but I am having problems to configure Gradle's JVM. When I start a new Gradle project I am not allowed to define JVM as my JAVA_HOME variable. The following screenshots show what is happening: As you can see Intellij says that my JAVA_HOME variable...

How can IntelliJ refactor class constants to an external class?


java,intellij-idea,android-studio
I have a series of 30 or so private class constants declared and used in Fragment.java. I want to refactor the declarations into public declarations in Constants.java such that all occurrences of VARIABLE_NAME in Fragment.java are replaced with Constants.VARIABLE_NAME Tips appreciated on how to use this. I am using Android...

Install Android app on device through wifi - no usb or emulator


android,debugging,android-emulator,usb,wifi
Just as it says in the title. It seems my smartphone data connectors are broken, and the emulators run far too slow on my computer (surprisingly because it is i7). So, is there any way I can use an alternative to usb debugging through WIFI instead of usb? ...

How to disable plugin suggestions in Intellij IDEA?


intellij-idea
In Intellij IDEA how can I disable plugin suggestions? Whenever I create a yml plugin in a NEW project it will suggest a plugin to me that I have already ignored and is annoying.

Intellij IDEA long processing for grails app with warning “too much output to process”


grails,intellij-idea,jvm
I new to Intellij for Grails app while run the app it execute lot of thing with the warning "Too much output to process" & takes comparatively more time to start the server. Below is the log screen (AbstractAutowireCapableBeanFactory.java:539) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) at...

Can somebody explain why this is the result? [on hold]


java,debugging
public boolean isNumber(String s) { String a = s.trim(); if(a == null || a.isEmpty()){ return false; } boolean dFlag = false; boolean eFlag = false; boolean nFlag = false; for (int i = 0; i< a.length();i++){ char c = a.charAt(i); if (c == '+' || c == '-'){ if (i...

IntelliJ correctly using Libraries


java,intellij-idea,jar
I'm using IntelliJ without a build tool for a project, I build it as a jar. Now I'm using the iText library for PDF(s), if I put all the iText jars into a folder and add it in IntelliJ, I can use the iText functions and if the program works,...

Unable to run Java code with Intellij IDEA


java,intellij-idea
I have just downloaded the IDE, and I want to edit my first Java file with it, I'm not interested in creating a whole project, just editing the single file. So I opened the file from my desktop with Intellij IDEA as I set it as my default program for...

What are my next steps on finding the cause of this exception?


java,android,eclipse,debugging
I'm fairly new to Eclipse, Java, and Android programming. I've taken over development of an Android application. Someone has made a change several months ago that is causing the application to crash (exception) in code that is not part of the application code. I don't have any idea where or...