-1

I'm working on a big project that uses Karma + Mocha + TypeScript + Webpack in WebStorm.

In the karma.conf.js I specify which files to process this way:

for (const filePaths of filesToTest) {
  preprocessors[filePaths] = ['webpack', 'sourcemap']
}

preprocessors: {
  ...preprocessors
}

filesToTest contains all the test files, which take a lot of time to compile with Webpack.

In WebStorm there is a small play button besides the test, that allows to just run that specified test: enter image description here

Pressing this play button will compile all my test files taking a very long time, and then somehow WebStorm will just run the one test I need (its specified in the "files to test" part in the created run configuration).

So my question is: Is there a way in my karma.conf to "catch" this "files to test" parameter, so I could only preprocess the needed file (e.g. its an environment variable)?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
sydd
  • 1,824
  • 2
  • 30
  • 54
  • Does this answer your question? [Karma: Running a single test file from command line](https://stackoverflow.com/questions/29150998/karma-running-a-single-test-file-from-command-line) – Inigo Jul 03 '21 at 13:23
  • 1
    related ticket: https://github.com/karma-runner/karma/issues/3664 – lena Jul 03 '21 at 19:28
  • @Inigo Nope, that answer has nothing about WebStorm – sydd Jul 04 '21 at 22:20
  • Then your question needs to make more sense. You said "somehow WebStorm will just run the one test I need". You think Webstorm has some magic? No, it uses whatever API Karma supplies to selectively run tests, and I pointed you at that API. – Inigo Jul 05 '21 at 02:13

1 Answers1

0

Turns out its not possible as of June 2021. Jetbrains is on the opinion, that such thing is not needed since Karma startup time is so slow that its better to always compile all the test: https://youtrack.jetbrains.com/issue/WEB-49930

sydd
  • 1,824
  • 2
  • 30
  • 54