![]() If a test fails for unclear reason you can debug the test to find out whether the test is outdated or the changes you made to the source code break the intended behavior of your application. If the exact line is not in the stack trace, you will be taken to the test definition. The test file opens in the editor with the cursor placed at the test definition.įor failed tests, WebStorm brings you to the failure line in the test from the stack trace. To jump from a test result to the test definition, click the test name in the Test Runner tab twice, or select Jump to Source from the context menu, or just press F4. 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 Ctrl+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. 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. 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. 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.
0 Comments
Leave a Reply. |