PhpStorm 2017.2 Help

Protractor

You can run and debug tests with Protractor right in PhpStorm. You can see the test results in a treeview and easily navigate to the test source from there.

On this page:

Before you start

  1. Make sure the Node.js runtime environment is installed on your computer.
  2. 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.

Installing Protractor

You can install Protractor locally, in your project, or globally. Global installation is preferable.

To install Protractor globally

  1. Open the built-in PhpStorm Terminal (press Alt+F12 or choose View | Tool Windows | Terminal on the main menu) and type npm install -g protractor at the command prompt.
  2. To download the necessary binaries, type webdriver-manager update.
See also Getting Started on the Protractor official website.

Running tests

Protractor tests are launched only through a run/debug configuration.

To create a Protractor run configuration

  1. Open the Run/Debug Configuration dialog box (Run | Edit Configurations on the main menu).
  2. Click /help/img/idea/2017.2/new.png on the toolbar and select Protractor from the list. The Run/Debug Configuration: Protractor dialog box opens.
  3. Specify the Node interpreter to use, the location of the protractor package, and the path to the protractor.conf.js configuration file. If you followed the standard installation, PhpStorm detects all these paths and displays them in the corresponding fields.

To run tests via a run configuration

  1. Select the Protractor run/debug configuration from the list on the main toolbar and click /help/img/idea/2017.2/run.png to the right of the list.
    ws_select_run_configuration.png
    The Selenium Server starts automatically without any steps from your side.
  2. View and analyze messages from the server in the <current_run_configuration_name> tab of the Run tool window.

Navigation

With PhpStorm, 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 Go To | Test or Go To | Test Subject 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.

ws_test_jump_to_test
The test file opens in the editor with the cursor placed at the test definition.

Debugging tests

A debugging session for Protractor tests is started only through a run/debug configuration.

To start debugging tests

  1. Create a Protractor run/debug configuration as described above.
  2. Select the Protractor run/debug configuration from the list on the main toolbar and click /help/img/idea/2017.2/debug.png to the right of the list.
    ws_select_run_configuration.png
  3. 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.

Last modified: 12 October 2017

See Also