Home / PhpStorm / Running Karma Tests
Running Karma Tests in PhpStorm
Integration requires the Karma Plugin - How to install a PhpStorm plugin
Setting up the Karma config
- Find the Karma configuration file in your project panel
- Your project window shows all of the files in your project. It's visibility can be toggled by choosing the View > Tool Windows > Project menu item.
- You Karma config file should look something like this:
karma.conf.js
.
- Right-click the Karma config file and choose **Run 'karma.conf.js'
- This will run the Karma tests, and save a run configuration. Assuming your tests ran properly, you are done with the setup step.
- To edit the configuration, you can choose the Run > Edit Configurations... menu item.
- Alternatively, you can also find the Edit Configurations... option in the dropdown located on the PhpStorm toolbar, near the Run button (has green "play" icon).
Running Karma Tests
- First, make sure the your Karma configuration is the current configuration for the PhpStorm Run tool
- You can select it from the dropdown located on the PhpStorm toolbar, near the Run button (has green "play" icon).
- Alternatively, you can choose Run > Run... from the menu.
- Now, you can run your tests
- Click the Run button (has green "play" icon) on the PhpStorm toolbar
- Alternatively, you can choose Run > Run 'karma.conf.js' from the menu.
- Once your tests have run, there is a helpful "Auto-test" button that will automatically run your tests for you while you code. It is located in the Karma window panel that pops up when you run your tests. Look for it right below the Run button.