gulp-karma-mocha debugging

Hi all
I am able to debug a mocha file through a karma runner run/debug configuration, execution stops in breakpoints and everything is fine. But, when I try to do the same but launching a karma task from gulp (using a gulp run/debug configuration), debugging of test files is not working, running is done instead. I am using mocha as testing framework.

I think the problem can be in the way webstorm works with gulp files rather than the karma config file (as karma debugging is working ok). The task definition in the gulp I am using is as follows:

gulp = require 'gulp'
concat = require 'gulp-concat'
karma = require 'gulp-karma'
  
servicesTest = () ->
  services4test = [
    'www/lib/jquery-1.10.2.js',
    'www/lib/lodash-241.underscore-152.js',
    'www/lib/ionic/js/ionic.bundle.js',
    'www/js/**/*.js',
    'test/lib/**/*.js',
    'test/services/*-test.js'
  
]
  gulp.src services4test
  .pipe karma {configFile: 'karma.conf.js', action: 'start', singleRun: true, frameworks:['mocha', 'sinon-chai']}
  .on 'error', (err) ->
    console.log("ERR test-services: #{err}")
    throw err

gulp.task 'test-services', servicesTest
  

does anyone know if this debugging issue is supported by webstorm and, if so, what is the right way to proceed? I can switch and debug using the karma run/debug configuration, but it is a bit annoying switching between the two ones and I am more comfortable doing this kind of things through gulp.

cheers

w

3 comments
Comment actions Permalink

Unfortunately, such a workflow isn't supported.
If "singleRun" is "false", then it's possible to setup a "JavaScript Debug" run configuration in this way:
0. Karma server is running
1. Create "JavaScript Debug" run configuration with "http://localhost:9876/debug.html" URL (or maybe another URL depending on your karma configuration).
2. Click debug fpr the created "JavaScript Debug" run configuration and breakpoints in your Karma tests should be hit.

As a side note: seems setting up Karma run configuration could be avoided, you just right-click your "karma.conf.js" and select "Debug". Does it work for you?

0
Comment actions Permalink

Thanks for the response.
Right clicking debug on karma.conf.js it is effectively working, as I told in the first email. But I tried using singleRun: false in the gulp file configuration but nothing happens.

So, take this issue as a suggestion for future releases ;)

Cheers

w

0

Please sign in to leave a comment.