Debugging Jasmine Node tests

Debugging Jasmine Node tests

One of the things that frustrate me the most is failing tests with no apparent error message. A nice thing about Jasmine-node is that it can be run as a regular NodeJS process and as such can be remotely debugged.

Here is a short ‘How to’ guide on debugging problematic tests:

  1. Locate your global jasmine cli - should be something like:
  1. Execute the cli.js as a regular NodeJS script with –debug-brk: that tells the script to break automatically at the first line of the script. like so:
  node --debug-brk /usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/cli.js tests/spec/myServiceSpec.js.

This will produce an output like:

  debugger listening on port 5858
  1. Start a remote debugger on the port (5858) - I use Webstorm for remote debugging sessions but this can also be done with other tools such as Node Inspector


I was trying to debug a process that was running on a Vagrant virtual machine and for some reason kept getting ‘connection refused’. I needed to manually map a port when connecting to the Vagrant machine like so:

vagrant ssh -- -L 7000:

Then, from within the guest machine I set the debug port to 7000:

node --debug-brk=7000 /usr/local/lib/node_modules/jasmine-node/lib/jasmine-node/cli.js tests/spec/myServiceSpec.js

At this point the host machine was able to connect to port 7000. You can verify this by running:

telnet 7000
Javascript Architect

Frontend Group