Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working from CLI with mocha-phantomjs #3

Open
treyhunner opened this issue Aug 6, 2015 · 5 comments
Open

Not working from CLI with mocha-phantomjs #3

treyhunner opened this issue Aug 6, 2015 · 5 comments

Comments

@treyhunner
Copy link

I was trying to add code coverage to Parsley.js (on this branch).

I tried running the tests with the mocha-phantomjs-istanbul hook:

mocha-phantomjs -k mocha-phantomjs-istanbul test/index.html 

The tests executed but no files were generated. I ran istanbul report afterward and istanbul generated an empty report (0% coverage, no files).

I think I'm missing something. Do I need to tell mocha-phantomjs-istanbul which files need to be istanbul-instrumented or anything?

@danvk
Copy link

danvk commented Oct 23, 2015

Try downgrading to mocha-phantomjs 3.x. I think mocha-phantomjs-istanbul needs to be updated for mocha-phantomjs 4.x.

@arnoudius
Copy link

I had the same issue and I solved it like so:

  1. First I had to generate the instrumented version of the source via
    istanbul instrument -i ./src -o ./instrumented
  2. For this project I am using RequireJS so I had to point to the instrumented code (instead of the actual code) in the RequireJS config file of my test project (using the baseUrl property).
  3. Then I ran mocha-phantomjs -k mocha-phantomjs-istanbul ./test/test-runner.html which then generated the coverage.json file
  4. Finally I ran istanbul report to generate the HTML report

@juancarlosfarah
Copy link

The steps described by @arnoudius worked for me too.

@hepabolu
Copy link

It's more than a year later, istanbul became nyc, mocha-phantomjs became mocha-phantomjs-core and my code is converted from ES6 using Babel. If anyone could help to update the steps outlined by @arnoudius I'd be very grateful.

@sakshij
Copy link

sakshij commented Nov 28, 2017

@arnoudius The steps mentioned by you worked like a charm. However, istanbul only checks files which are included in the tests instead of looking at all instrumented files when reporting coverage.
I have added include-all-sources: true to .istanbul.yml but that does not help.
Kindly suggest a solution for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants