vendredi 30 janvier 2015

How to remove duplication in the script files loaded in index.html and karma?

I have a project that was initially created using the yeoman angularjs generator. I run my unit-tests using karma and currently whenever I add a new script to the index.html I also need to add it to the karma.conf.js file so it is accessible for me to test. I don't like this duplication, it slows me down and it is error prone (e.g. I can add it to index.html and forget to add it to karma.conf.js).


The example projects that I see do something like this in the karma.conf.js:



files: [
'app/bower_components/jquery/jquery.js',
'app/bower_components/lodash/dist/lodash.js',
'app/scripts/**/*.js',
'test/spec/**/*.js'
]


That is fine for test specs but not for actual application scripts because the order matters there. Also they have to specifically specify each bower component because the order also matters there


I thought about creating a task that copies the file paths from index.js and modifies and adds it to karma.conf.js before I run the unit-tests, but before I do that I thought I would ask if anyone knows a better way to remove/manage this duplication.


I know if I was using a file and module loader I would not have this issue, but I don't intend to use that at least for now.


Aucun commentaire:

Enregistrer un commentaire