linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 82 forks source link

Need code coverage with istanbul #385

Closed vairabagni closed 8 years ago

vairabagni commented 8 years ago

How to configure inbuilt testem to get istanbul code coverage report? Please guys help me. Otherwise I have to stop using lineman and start integrating grunt or gulp

bwilln9 commented 8 years ago

I made the config/spec.json file look like this; it generates instrumentation for istanbul, but the coverage report shows no files covered. Not entirely working, but part of the way there!

{
  "framework" : "jasmine",
  "launch_in_dev": ["Chrome"],
  "launch_in_ci" : ["PhantomJS"],
  "before_tests": "istanbul instrument --output generated/instrumented generated/js/app.js",
  "after_tests": "istanbul report --dir generated",
  "src_files" : [
    "generated/js/app.js",
    "generated/js/spec.js"
  ]
}

btw, I'm running 'lineman spec-ci' and have phantom installed and the phantomjs executable on PATH hth

bwilln9 commented 8 years ago

With a closer read of the docs for testem and istanbul, the above may not really be doing anything. What's really needed is a command to run the 'instanbul cover ...' command on 'testem ci'.

I tried the following simplistic approach just to see what would happen:

istanbul cover --config config/istanbul-config.yml node_modules/testem/testem.js ci -f config/spec.json -p 60630

But got a warning message like this:

"No coverage information was collected, exit without writing coverage information"

Not sure how to integrate the two at this point.

vairabagni commented 8 years ago

Both of these methods are not giving any results. Even if this mechanism works, then we may not get actual coverage report since generated/app.js is a combination of all vendor files as well. Also the line number of all app/js/*.js would be wrong.

How about karma-coverage. I am currently using this on lineman application. But instead of executing "lineman spec-ci" I would be executing "karma start config\cov.js" where "cov.js" is the karma config file. It is working. But with this approach I am not benefited much with lineman, karma is separately installed and executed independently.

searls commented 8 years ago

Closing due to inactivity. If someone has a PR that makes istanbul config easier in lineman, I'd welcome it.