IntelliJ IDEA 2017.1 Help

Creating JavaScript Unit Tests

This feature is supported in the Ultimate edition only.

IntelliJ IDEA provides integration with JavaScript unit testing frameworks thus providing rich coding assistance for writing JavaScript unit tests. To get framework-aware coding assistance, download the desired framework, configure it as a IntelliJ IDEA JavaScript library, and define its visibility and scope.

The visibility status of a library determines whether it can be used in one project (Project) or can be re-used at the IDE level (Global).

The scope of a library defines the set of files and folders in which the library is considered as library, that is, it is write-protected, excluded from check for errors and refactoring, but only affects the completion list and highlighting.

For details, see Configuring JavaScript Libraries.

To create JavaScript unit tests, perform these general steps

  • Create a folder test at the same level as the src folder.
  • Populate the test folder. For each production file, create a separate test file and name it as follows:
    <name of production file>.<Test>.js
  • Mark the folder where the tests are stored as a test source folder, see Configuring Content Roots.
  • If necessary, have IntelliJ IDEA detect and enable the required testing framework on-the-fly.

See Also

Last modified: 18 July 2017