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

Full Stack Example #1

Open
shellscape opened this issue Jan 15, 2015 · 2 comments
Open

Full Stack Example #1

shellscape opened this issue Jan 15, 2015 · 2 comments
Labels

Comments

@shellscape
Copy link

Do you have a start-to-finish example you could post which included wiring up instanbul to run the instrumentation?

@willembult
Copy link
Owner

To instrument istanbul I use browserify-istanbul in a gulp script like this (simplified):

var source = require('vinyl-source-stream');
var browserifyIstanbul = require('browserify-istanbul');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var istanbulReport = require('gulp-istanbul-report');

gulp.task('bundle-test', function() {
    return browserify({debug: true})
        .transform(browserifyIstanbul())
        .bundle()
        .pipe(source('test.js'))
        .pipe(gulp.dest('./bundle'))
});

gulp.task('test', ['bundle-test'], function() {
    return gulp.src('test-runner.html', {read:false})
        .pipe(mochaPhantomJS({
            phantomjs: {
                hooks: 'mocha-phantomjs-istanbul',
                coverageFile: './coverage.json'
            }
        }))
        .on('finish', function() {
            gulp.src('./coverage.json')
                .pipe(istanbulReport({
                    dir: './coverage',
                    reporters: ['html']
                }));
        });
});

You'll have to make sure your test-runner.html runs tests from the bundle using mocha. See mocha-phantom-js for details on how to do that.

@shellscape
Copy link
Author

Awesome. Thanks for putting this together, I'll give it a shot here soon and post my experience.

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

No branches or pull requests

2 participants