最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Rundebug node.js testcases with jasmine in Webstorm 11 - Stack Overflow

matteradmin3PV0评论

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 mand line 'jasmine' mand 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?

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 mand line 'jasmine' mand 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?

Share Improve this question edited Nov 9, 2015 at 9:01 Ph0en1x asked Nov 8, 2015 at 18:12 Ph0en1xPh0en1x 10.1k8 gold badges55 silver badges97 bronze badges 1
  • Why not jetbrains./webstorm/help/… – timothyclifford Commented Nov 9, 2015 at 9:06
Add a ment  | 

3 Answers 3

Reset to default 11

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 mand 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.

Jasmine works with the JSTestDriver which you get out-of-the-box with WebStorm 11: https://www.jetbrains./webstorm/help/enabling-javascript-unit-testing-support.html

This page also details how to add Jasmine within JSTestDriver: https://www.jetbrains./webstorm/help/preparing-to-use-jstestdriver-test-runner.html

At a high level you're going to:

  1. Install JSTestDriver from JetBrains plugin repo
  2. Configure it as a WebStorm JavaScript library (https://www.jetbrains./webstorm/help/configuring-javascript-libraries.html#configure)
  3. Open jsTestDriver.conf and type the following code in it:

load:

lib/jasmine/jasmine.js

lib/jasmine-jstd-adapter/JasmineAdapter.js

WebStorm doesn't manage test running directly. This job is done by a test runner. WebStorm supports several test runners - Mocha, Karma, JsTestDriver, nodeunit. Most of them can execute Jasmine tests

Post a comment

comment list (0)

  1. No comments so far