Search code examples
unit-testingmeteorwebstormangular-meteor

How to debug Meteor unit test in WebStorm?


I was following Meteor's Angular testing guide and it told me to run unit test by using this command:

meteor test --driver-package practicalmeteor:mocha

I'm using WebStorm to edit my Meteor code, so I want to know is there any way to run/debug unit test in WebStorm?


Solution

  • Running tests

    You have to make a Run/Debug Configuration in Webstorm for Meteor. You'll have to set the program arguments correctly:

    test --driver-package practicalmeteor:mocha

    You run the tests by running this configuration.

    Debugging tests client-side

    You can use the previous configuration and debug using the browser's console.

    Debugging tests server-side

    Make a new Meteor configuration with arguments:

    test --driver-package practicalmeteor:mocha --debug-port 5858.

    Running this configuration you'll see an output similar to:

    W20170409-20:19:21.287(2)? (STDERR) Debugger listening on [::]:5959

    You can then debug the code by browsing to: http://localhost:8080/debug?port=5959

    Note: in my case the port in the console differs from the port in the configuration. I have to use that port in the url.