With IntelliJ IDEA, you can test Node.js applications using numerous frameworks. Since May 2018, Nodeunit is deprecated. See the Nodeunit official website for details.
Before you start
Make sure the Node.js plugin is enabled on the Settings/Preferences | Plugins page, tab Installed, see Managing plugins for details.
Download and install a testing framework.
Creating and running unit tests for Node.js applications
Creating Nodeunit tests
Create a folder test at the same level as the src folder
Populate the test folder. For each production file, create a separate test file.
Mark the folder where the unit tests are stored as a test source folder, see Content roots.
Creating a Nodeunit run configuration
Open the Run/Debug Configuration dialog by choosing from the main menu.
Click the Add button on the toolbar and select the Nodeunit configuration type.
- In the dialog that opens, specify the following:
The name to identify the configuration.
The working directory. This can be the project root folder or the parent directory for the test folder.
- The scope of tests to run.
Apply the changes and close the dialog.