
In the Test Runner tab, click on the toolbar. Click this link to jump to the source code. The name of file with the selected test is show as a link. Use the Click to see the difference link to open the Difference viewer and compare the actual result with the expectation. Monitor test execution and analyze test results in the Test Runner tab of the Run tool window, see Explore test results for details. Select the Mocha run/debug configuration from the list on the main toolbar and click to the right of the list. folder1/folder2/test/*.test.js.Ĭhoose the interface used in the test to run.

If the files with tests are stored in a test folder, specify the path to this folder in the pattern relative to the working directory, for example.

You can also define patterns to run only the tests from matching files, for example, *.test.js. This can be a specific test or suite, an entire test file, or a folder with test files. To do that, add the -watch flag in the Extra Mocha options field. To change this predefined setting, specify the path to the desired folder.Ĭonfigure rerunning tests automatically on changes in the related source files. By default, the Working directory field shows the project root folder. Specify the working directory of the application. Specify the Node interpreter to use and the location of the mocha package. The Run/Debug Configuration: Mocha dialog opens. Open the Run/Debug Configuration dialog ( Run | Edit Configurations on the main menu), click in the left-hand pane, and select Mocha from the list. You can also see whether a test has passed or failed right in the editor, thanks to the test status icons and in the gutter. Run a single test from the editorĬlick or in the gutter and select Run from the list. With WebStorm, you can quickly run a single Mocha test right from the editor or create a run/debug configuration to execute some or all of your tests. In the embedded Terminal ( Alt+F12), type:Ĭreate tests according to the instructions from the Mocha official website.
#GETTING STARTED WITH WEBSTORM NODEJS INSTALL#
Install the Chai expectation library as an efficient replacement for Node.js standard assert function. Learn more from Getting Started on the Mocha official website. Npm install -save-dev mocha to install Mocha as a development dependency. Npm install -g mocha for global installation.

Npm install mocha for local installation in your project. In the embedded Terminal ( Alt+F12), type one of the following commands: Make sure the JavaScript and TypeScript and Node.js required plugins are enabled on the Settings | Plugins page, tab Installed, see Managing plugins for details.Īlthough you can use any framework, the recommended one is Mocha. Make sure you have Node.js on your computer. Next to the test, in the editor, WebStorm shows the status of the test with an option to quickly run or debug it. You can run Mocha tests from outside WebStorm, examine test results arranged in a treeview, and easily navigate to the test source from there. The current page describes testing with Mocha, which is a JavaScript test framework that is especially helpful for executing asynchronous test scenarios. See the Nodeunit official website for details. With WebStorm, you can test Node.js applications using numerous frameworks.
