![]() ![]() To jump between a test and its subject or vice versa, open the file in the editor and select Go to | Test or Go to | Test Subject from the context menu, or just press Control+Shift+T. suffix and is located either next to the source file or in a test folder. Such navigation works only if the test file follows popular naming conventions, for example, has a. With WebStorm, you can jump between a file and the related test file or from a test result in the Test Runner Tab to the test. To rerun a specific failed test, select Run on its context menu.Īlternatively, click in the gutter next to a failed test and select Run from the list.įor more information, refer to Rerunning tests. WebStorm will execute all the tests that failed during the previous session. 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. For more information, refer to Explore test results. Monitor test execution and analyze test results in the Test Runner tab of the Run tool window. Select the Mocha run/debug configuration from the list of configurations and click in the list or on the toolbar. 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. 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: For more information about plugins, refer to Managing plugins.Īlthough you can use any framework, the recommended one is Mocha. Press Control+Alt+S to open the IDE settings and then select Plugins. Make sure the Node.js plugin is enabled in the settings. 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. For more information, refer to the Nodeunit official website. With WebStorm, you can test Node.js applications using numerous frameworks. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |