Running Nodeunit Tests
On this page:
- Creating and running unit tests for Node.js applications
- Enabling unit testing for Node.js applications
- Creating Nodeunit tests
- Creating a Nodeunit run configuration
This topic provides guidelines in Node.js-specific unit testing procedures. For general information on testing in PhpStorm, see the Testing section.
Creating and running unit tests for Node.js applications
- Enable nodeunit support.
- Write the unit tests.
- To have PhpStorm recognize the unit tests and detect the corresponding production source code, mark the folder where the unit tests are stored as test folder.
- Create a run configuration of the type Nodeunit.
- Launch unit tests and monitor test results in the Run tool window.
Enabling unit testing for Node.js applications
- Make sure that the Node.js plugin is enabled. The plugin is activated by default. If the plugin is disabled, enable it on the Plugins page as described in Enabling and Disabling Plugins.
- Download and install the Node.js runtime environment.
- Download and install the nodeunit testing framework
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 tests are stored as test folder.
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.
- The path to the Node.js installation to use.
If you have appointed one of the installations as default, the field displays the path to its executable file.
- 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.