WebStorm is my IDE of choice when it comes to debugging Node apps. Read on if you haven’t configured Mocha Tests debugging yet.
1) Prerequisites:
- Application with Mocha Unit Tests
- WebStorm with Node plugin enabled
2) Add Mocha to your Run/Debug Configurations
Open the Edit Run/Debug Configurations Dialog:
Or go to Run | Edit Configurations ...
Then Add a new Mocha Configuration:
If node is configured properly in WebStorm, you should only have to edit the Name
and Test directory
which is the path to your tests folder.
The following fields are mandatory:
Node Interpreter
path to Node on your machine.Working Directory
path to your project directory.Mocha Package
path to Mocha installation home. If you installed Mocha through npm, WebStorm will detect it automatically.User Interface
select the Mocha Interface that corresponds to the way your wrote your tests.Test Directory
path to your test folder.
Press OK
.
3) Run or Debug your tests
Make sure your have your unit test config selected in the Run/Debug Configuration