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 creating JSON report - missing coverage variable? #5

Open
bcwatson22 opened this issue Sep 18, 2017 · 0 comments
Open

Not creating JSON report - missing coverage variable? #5

bcwatson22 opened this issue Sep 18, 2017 · 0 comments

Comments

@bcwatson22
Copy link

Hi, I've been trying to use your plugin but am having some difficulty with it.

I'm using gulp-mocha-phantomjs to run the tests and gulp-istanbul to instrument the code, setting coverageVariable: '__coverage__' in the options object - which appears in the outputted instrumented file. However, when I then try to use mocha-phantomjs-istanbul as the Phantom hook in the subsequent task it never creates the coverage.json file.

I've been consoling from the node_modules/mocha-phantomjs-istanbul/index.js and it doesn't seem to be able to find the coverage variable, getting to line 14 if (!coverage) {...} and then returning. My gulp tasks are as follows:

var mochaPhantomJS = require('gulp-mocha-phantomjs'),
    istanbul = require('gulp-istanbul');

gulp.task('test-instrument', function () {
    return gulp.src('./source/assets/js/modules/*.js')
        .pipe(istanbul({
            coverageVariable: '__coverage__',
            coverageReporter: {
                 includeAllSources: true
            }
        }))
        .pipe(gulp.dest('./source/assets/js/instrumented'));
});

gulp.task('test-dev', ['test-instrument'], function () {
    return gulp.src('./test/unit/template.html', {read: false})
        .pipe(mochaPhantomJS({
            phantomjs: {
                hooks: 'mocha-phantomjs-istanbul',
                coverageFile: './test/unit/coverage.json'
            },
            reporter: 'spec'
        }))
        .on('error', stack.mochaSilentFail);
});

Am I doing anything wrong? Or if it's an issue with how the code is being instrumented please can you suggest an alternative way of doing this?

Really appreciate your help, cheers!

@bcwatson22 bcwatson22 changed the title Not creating report - missing coverage variable? Not creating JSON report - missing coverage variable? Sep 19, 2017
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

1 participant