# Test React applications

You can run and debug [Jest tests](https://facebook.github.io/jest/) in React applications [created
with generators](react.html#creating_react_app_with_generators). Before you start, make sure the react-scripts package is added to the dependencies object of your `package.json`.

You can run and debug Jest tests right from the editor, or from the Project tool window, or via a run/debug configuration. For more information, refer to [Jest](running-unit-tests-on-jest.html).

## Run a test from the editor

Procedure:

* Click ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app-client.expui.run.run.svg) or ![the Rerun icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.actions.rerun.svg) in the gutter and select Run <test_name> from the list.

![Run single test from the editor](https://resources.jetbrains.com.cn/help/img/idea/2026.2/ws_run_test_from_editor_600.animated.gif)  You can also see whether a test has passed or failed right in the editor, thanks to the test status  icons ![Test passed](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.runConfigurations.testState.green2.svg) and ![Test failed](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.runConfigurations.testState.red2.svg) in the gutter.

## Run tests via a run/debug configuration

### Create a Jest run/debug configuration

Procedure:

1. Open the [Run/Debug Configuration](run-debug-configurations-dialog.html) dialog (`Run | Edit Configurations` in the main menu), click ![the Add button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.general.add.svg) in the left-hand pane, and select Jest from the list.  The [Run/Debug Configuration: Jest](run-debug-configuration-jest.html) dialog opens.

> **Tip:**
> Alternatively, select a test file in the   Project tool window  (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)))  and select Create <filename> from the context menu.

2. Specify the Node.js runtime to use and the  working directory of the application. By default, the Working directory field shows the project root folder. To change this predefined setting, specify the path to the desired folder.

3. In the Jest package field, specify the path to the react-scripts  package.

4. In the Jest options field, type `--env=jsdom`.

![Testing React: Jest run configuration](https://resources.jetbrains.com.cn/help/img/idea/2026.2/react_run_config_jest.png)

### Launch tests via a run/debug configuration

Procedure:

1. Select the Jest run/debug configuration from the list of configurations and click ![the Run icon](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.run.run.svg) in the list or on the toolbar.

2. Monitor test execution and analyze test results in the Test Runner tab of the Run tool window. For more information, refer to [Explore test results](viewing-and-exploring-test-results.html).

## Debug tests

Procedure: Debug tests

1. Select the Jest run/debug configuration from the list on the main toolbar and click ![the Debug button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.run.debug.svg) to the right.

2. In the [Debug tool window](debug-tool-window.html) that opens,   proceed as usual: [step through the program](stepping-through-the-program.html),  [stop
and resume](starting-the-debugger-session.html#pause-resume)  program execution, [examine it when suspended](examining-suspended-program.html), explore the call stack and variables, set watches, evaluate variables, [view actual HTML DOM](viewing-actual-html-dom.html), and so on.

To ignore source maps and step through the actually executed code, press ![the Disable Source Maps toggle button](https://resources.jetbrains.com.cn/help/img/idea/2026.2/sourceMapDisable.png) on the toolbar of the Debug tool window.

