You can run and debug tests with Protractor right in IntelliJ IDEA. You can see the test results in a treeview and easily navigate to the test source from there.
Before you start
- Make sure the Node.js runtime environment is installed on your computer.
- Install and enable the NodeJS repository plugin on the Plugins page as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
You can install Protractor locally, in your project, or globally. Global installation is preferable.
To install Protractor globally
- Open the built-in IntelliJ IDEA Terminal (Alt+F12) and type
npm install -g protractorat the command prompt.
- To download the necessary binaries, type
Protractor tests are launched only through a run/debug configuration.
To create a Protractor run configuration
- Open the Run/Debug Configuration dialog box ( on the main menu).
- Click on the toolbar and select Protractor from the list. The Run/Debug Configuration: Protractor dialog box opens.
- Specify the Node interpreter to use, the location of the
protractorpackage, and the path to the
protractor.conf.jsconfiguration file. If you followed the standard installation, IntelliJ IDEA detects all these paths and displays them in the corresponding fields.
To run tests via a run configuration
- Select the Protractor run/debug configuration from the list on the main toolbar and click to the right of the list. The Selenium Server starts automatically without any steps from your side.
- View and analyze messages from the server in the <current_run_configuration_name> tab of the Run tool window.
With IntelliJ IDEA, you can jump between a file and the related test file. Navigation from a test result in the Test Runner Tab to the test is also supported.
To jump between a file and the related test file
Open the file in the editor and choose or on the context menu, or just press Ctrl+Shift+T.
To jump from a test result to the test
Select the test name in the Test Runner tab and choose Jump to Source on the context menu. The test file opens in the editor with the cursor placed at the test definition.
A debugging session for Protractor tests is started only through a run/debug configuration.
To start debugging tests
- Create a Protractor run/debug configuration as described above.
- Select the Protractor run/debug configuration from the list on the main toolbar and click to the right of the list.
- In the Debug Tool Window that opens, proceed as usual: step through the tests, stop and resume test execution, examine the test when suspended, etc.