What is the proper way to get the karma test cover

2019-07-04 11:26发布

问题:

I'm using karma to run unit tests and generate coverage reports. That all works fine but I want to publish the lcov.info file to Code Climate from Travis CI. I've done it before and it works great, but the url from that test runner was static.

The issue is that karma creates a subfolder for each instance it runs such as test/coverage/PhantomJS 1.9.7 (Mac OS X)/lcov.info. Is there a clean way to get that url to feed into travis? I don't want to have to remember to update a hardcoded value every time PhantomJS gets updated. Does anyone know if the .travis.yml file supports something like glob patterns.

Thoughts?

回答1:

A glob pattern will work and I'm using it successfully with a karma/travis/codeclimate set up.

Using

codeclimate < test/coverage/**/lcov.info

should work assuming have the CODECLIMATE_REPO_TOKEN variable set.

Also, options to change the subdirectory structure is being discussed on https://github.com/karma-runner/karma-coverage/pull/62.