Search code examples
angularintellij-ideakarma-runnerwebstormangular7

Is there a way to specify Angular configurations within karma.conf.js in IntelliJ?


We have two different configurations (before Angular 6 called environments) for our Angular app. Now we run Karma test and I don't find an option within IntelliJ/WebStorm, how to specify the correct configuration.

I've found something "old", which was defined in the karma.config.js, like this:

config.set({
...
  plugins: [
    ...
    require('@angular/cli/plugins/karma')
  ]
  angularCli: {
    environment: 'dev'
  }
});

But this seem not to work anymore, also with the newer Angular version, the plugin changed to require("@angular-devkit/build-angular/plugins/karma").

Is there a way to start a Karma test within IntelliJ/WebStorm with a specific configuration?

From terminal it is easy - ng test --configuration=dev.


Solution

  • Will be possible in upcoming IDEA 2019.1 - it allows passing cli arguments in karma run configuration (see WEB-29620) using karma options: field (https://www.jetbrains.com/help/webstorm/2019.1/run-debug-configuration-karma.html):

    enter image description here