Debugging mocha chai unit tests in IDEA 12.1.4

Hi
How do I debug a mocha / chai unit test. I want to set breakpoints and step into the code.
currently I saw that there are workarounds that have been written ,  for example runing a testerjs file that runs  the actual mocha tests.
http://ronderksen.nl/2012/05/03/debugging-mocha-tests-in-webstorm/

Isnt there a built in way in the intellij IDEA 12.1,4 environment to debug mocha ?
Is there a way in  IDEA 13 ?
Thanks.

5 comments
Comment actions Permalink

Hi,

Yes, it's possible to debug mocha chai unit test is IDEA 12.1.4:
It can be accomplished in the same way as debugging any other Node application.
This tutorial contains detailed instructions:
http://www.dzone.com/links/r/debugging_mocha_unit_tests_with_webstorm_step_by.html

IDEA 13 with installed NodeJS plugin supports mocha out-of-the-box: https://www.youtube.com/watch?v=4mKiGkokyx8

Hope it will help.

0
Comment actions Permalink

Can you debug chai without having mocha in webstorm?

0
Comment actions Permalink

Yes, if you can debug it with general Node.js run configuration.

0
Comment actions Permalink

Thanks but I am getting this error 'describe is undefined'



for this code

 
var chai = require('chai');
var
expect = chai.expect;
var
foo = require("../foo");

describe('foo', function () {
  

0
Comment actions Permalink

I guess your original problem is not with debugging, but with running.
If you're running tests in Node.js environment, then, "describe" is usually provided by mocha (http://mochajs.org) or jasmine (https://github.com/jasmine/jasmine-npm). Here "chai" won't help, as it is an assertion library, not testing framework.

0

Please sign in to leave a comment.