Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run/debug node.js testcases with jasmine in Webstorm 11

I install Webstorm 11 and want to run my tests (for node.js app) implemented with Jasmine. However it's not easy to do that. I could just type in command line 'jasmine' command and test will be runned, but in this case I'm not able to debug code. So is there a way to configure Webstorm to deal with jasmine specs as it should?

like image 706
Ph0en1x Avatar asked Nov 08 '15 18:11

Ph0en1x


1 Answers

Ok, so while no one answer at the moment I will try to provide my version: This flow will allow to run jasmine testsute from Webstrom and debug testcases

  1. install jasmine (ither locally or globally)
  2. in project folder create folder 'spec/support' In this folder place jasmine.json

    tests configuration example:

    {
    "spec_dir": "tests",
    "spec_files": [
        "**/*[sS]pec.js"
    ],
    "helpers": [
        "helpers/**/*.js"
    ]
    }
    
  3. Create node.js configuration in Webstorm

  4. In this configuration select source file - jasmine executable file (for localy installed jasmine it will be 'node_modules\jasmine\bin\jasmine.js' )

So you are ready. However at the current moment when trying to debug this configuration - it fails with error:

Cannot stop on breakpoint due to internal error org.jetbrains.v8.V8CommandProcessor$1:

If you faced with it - you need to change Webstom configuration and set this settings:

-Dnodejs.debugger.use.jb.support=false For more details check there:

So this allow you to run jasmine tests and debug them. However there is still some things which this solution not able to do:

  1. Run individual testcases
  2. Run individual testcases with right click button and Run command from menu

Jetbrains, if you reading this - please fix this already. I started play with node in Webstorm 3 years ago and since that moment and dozens of version there is still no nice way to run tests. It's ridiculous.

like image 133
Ph0en1x Avatar answered Oct 06 '22 23:10

Ph0en1x