Copying links from index.html to karma.conf.js automatically

I am trying to create karma.conf.js for my testing.

There are already 30 tags in my application that link to my code. I am writing my AngularJS code in a modular structure as recommended here .

I wonder how else to write all the referee in karma.conf.js .. Does anyone know a solution for this?

I looked at https://preview.npmjs.com/package/karma-loadscripts-preprocessor , but that didn't help. It seems to load external scripts from cdn sources.

I got a little stuck right before writing my own shell script that does the job for me.

+5
source share
3 answers

In my experience, this is not a big problem in angular projects. Incoming files do not change too often, and they are managed manually. Sometimes it also happens that the Karma file has different options, because you may want to make fun of some modules.

If you are truly committed to being dry and you are using the angular generator in Yeoman, the solution may be to enable the built-in version of your application in Karma

0
source

In your karma.conf.js file, you can link to several files in a directory or subdirectories. For the properties of the files in your karma.conf, you can do the same as shown below.

files: [ 'www/js/*.js', 'www/**/*.js' ] 

The first show will get everything in the js folder. However, the second will give you all the javascript files in the www / folder and subfolders, including the js / folder.

Hope this helps.

0
source

I faced the same challenge as you. I don’t want to manually include every script that I use in my application in the karma configuration, but I want to check out scattered javascripts.

I myself created a karma preprocessor to include all the local scripts from the html file. It works for my own projects, I hope this is for you too.

https://www.npmjs.com/package/karma-preprocessor-includelocalscripts

Take a look at this and feel free to comment.

0
source

Source: https://habr.com/ru/post/1200822/


All Articles