How WebStorm Karma plugin does to load the necessary angular modules on the karma.conf ? (segrey?)

So,  I am building a test explorer for angular. In this test explorer I am loading my own karma.conf with the necessary configuration for the test explorer to work

https://github.com/Raagh/angular-test-explorer/blob/feature/run-tests/src/config/test-explorer-karma.conf.ts

this dictates that the modules "karma-jasmine"  "karma-chrome-launcher" and "@angular-devkit/build-angular/plugins/karma" are installed as dependencies in the test explorer, unfortunately sometimes this gives compatibility issues with some projects.

how does the current js-karma plugin loads those modules from the project that is using the plugin( the user's project )?

I cant figure it out from the code here : https://github.com/JetBrains/intellij-plugins/blob/8580eaf89f4f92f70d18675e570ccb1fd212a59e/js-karma/resources/js_reporter/karma-intellij/lib/intellij.conf.js

Thanks for your help

6 comments

You're right, js-karma doesn't load any project's dependencies explicitly.

1

thanks, I know I been a pain in the ass with this questions ahaah. I am very close to have something like an mvp :)

0

Cool! Feel free to ask any questions regarding karma integration.

0

can you explain how you guys pass the users karma.conf.js path as a parameter to your https://github.com/JetBrains/intellij-plugins/blob/8580eaf89f4f92f70d18675e570ccb1fd212a59e/js-karma/resources/js_reporter/karma-intellij/lib/intellij.conf.js ?

I have the path of the config file in memory but I have no idea how can the value be passed to my own conf and how is possible that it will webpack will take it for require.

I thought that I had this working but some changes made me notice that I did not.

Basically I have the path of **UserProject**/src/karm.conf.js  , this path is given to me by vscode while running my test explorer. from there I start angular through command line and I pass the path of my own karma conf my.karma.conf.ts, angular starts and runs that karma conf. Inside that karma conf I am trying to require the users karma.conf as you guys do, but for that I need the path.

since webpack compiles the code ahead of time I dont understand how I can pass that parameter to the karma.conf for a require

0

I think I figure it out again by myself, It works if I setup an enviroment variable and pass it to the spawn process I use to lunch angular, then when the process runs I just read that enviroment variable from my.karma.conf.ts. right?

0

Please sign in to leave a comment.