IntelliJ IDEA 11.1 Web Help

11.0+

JavScript unit tests are run in a browser against a test server which actually handles the testing process.

The test server does not necessarily have to be on your machine. IntelliJ IDEA has a local test server that is launched right from the IDE. This server allows you to capture a browser to run tests in, loads the test targets to the captured browser, controls the testing process, and exchanges data between the browser and IntelliJ IDEA, so you can view test results without leaving the IDE.

To get access to using the test server, download, install, and enable the JSTestDriver plugin from the JetBrains default repository. Then restart IntelliJ IDEA for the changes to take effect.

The test server loads tests to the browser according to the configuration files that define which test and corresponding production files should be loaded and in which order. JSTestDriver server treats *jstd and JSTestDriver.conf files as test runner configuration files. There are two ways to obtain configuration files:

To run JavaScript unit tests, perform these general steps:

To create a test runner configuration file manually
  1. In the Project tree, select the parent folder of the src (production) and the test folders, and choose New | File on the context menu.
  2. In the New File dialog box, that opens, type a name of the configuration file with the extension jstd or conf.
  3. Open the new file in the editor and specify the full path to the current folder and paths to the files to load relative to the current folder. Use wildcards to specify file name patterns. The required format is YAML, for more details, see description of test runner configuration files.

You can also have a configuration file generated automatically

To start a IntelliJ IDEA default JSTestDriver test server

If you are going to use a test server running on another machine or listening to another port, start it according to the server-specific instructions and specify its URL address in the Server ares of the Run/Debug Configuration: JSTestDriver dialog box.

  1. Make sure the JSTestDriver plugin is enabled.
  2. On the main menu, choose View | Tool Windows | JSTestDriver Server.
  3. In the JSTestDriver Server tool window, that opens, click the Run a local server toolbar button run.

To stop the server when you are through with unit testing, click the Stop the local server toolbar button stop.

To capture a browser for executing tests in
  1. With the JSTestDriver Server running, open the JSTestDriver Server tool window.
  2. Copy the contents of the Capture a browser using the URL read-only field.
  3. Open a browser of you choice and paste the copied URL address. The Remote Console of the JSTestDriver opens.
  4. Switch to the JSTestDriver Server tool window and click the icon that indicates the browser you just opened. IntelliJ IDEA displays a message informing you that it is ready for executing tests.
To create a JSTestDriver run configuration
  1. Open the Run/Debug Configuration dialog box by doing one of the following:
    • On the main menu, choose Run | Edit Configurations.
    • Press RunConfigurationRunConfiguration and choose Edit Configuration on the context menu.
  2. Click the Add button add on the toolbar and select the JSTestDriver configuration type.
  3. In the dialog box that opens, specify the test scope, configuration parameters, and activities to perform before test execution.
  4. Apply the changes and close the dialog box.
To launch JavaScript unit tests
  1. On the main toolbar, select the JSTestDriver run/debug configuration from the list.
  2. Click the Run button run  to the right of the list.

See Also

Procedures:

Reference:

Web Resources: