IntelliJ IDEA integrates with the nodeunit framework and makes it easier to test Node.js applications.
Creating and running unit tests for Node.js applications
Before you start
- Install the Node.js runtime environment and configure it as a local Node.js interpreter.
- Download and install the nodeunit testing framework.
- Download, install, and enable the Node.js plugin. The plugin is not bundled with IntelliJ IDEA, but it can be installed from the JetBrains plugin repository as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
Creating Nodeunit tests
- Create a folder called
testat the same level as the
- Populate the
testfolder. For each production file, create a separate test file.
- Mark the folder where the unit tests are stored as a test source folder, see Working with modules.
Creating a Nodeunit run configuration
- Open the Run/Debug Configuration dialog box by choosing on the main menu.
- Click the Add button on the toolbar and select the Nodeunit configuration type.
- In the dialog box that opens, specify the following:
- The name to identify the configuration.
- Specify the Node.js interpreter to use, see Configuring a local Node.js interpreter for details.
- The working directory. This can be the project root folder or the parent directory for the
- The scope of tests to run.
- Apply the changes and close the dialog box.
Last modified: 4 April 2018