Skip to content

Instantly share code, notes, and snippets.

Last active August 7, 2017 10:12
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
protractor coverage support with gulp and istanbul (not tested, this is just extracted from larger files to demonstrate how to get protractor coverage working)
var istanbul = require('istanbul'),
gulp = require('gulp'),
istanbul = require('gulp-istanbul');
gulp.task('js', function() {
return gulp.src('js')
includeUntested: true,
coverageVariable: '__coverage__'
var waitPlugin = require('./waitPlugin');
var istanbul = require('istanbul');
var collector = new istanbul.Collector();
// An example configuration file.
exports.config = {
baseUrl: 'http://localhost:3000/',
capabilities: {
'browserName': 'chrome'
specs: ['e2e/**/*.js'],
framework: 'jasmine2',
plugins: [{path: './waitPlugin.js'}],
onPrepare: function() {
var jasmineEnv = jasmine.getEnv();
jasmineEnv.addReporter(new function() {
this.specDone = function(spec) {
if (spec.status !== 'failed') {
browser.driver.executeScript('return __coverage__;').then(function(coverageResults) {
onComplete: function() {
istanbul.Report.create('cobertura', {dir: 'results/e2e/cobertura'})
.writeReport(collector, true);
istanbul.Report.create('lcov', {dir: 'results/e2e/lcov'})
.writeReport(collector, true);
var q = require('q');
var deferred = q.defer();
exports.resolve = function() {
deferred.resolve.apply(deferred, arguments);
exports.teardown = function() {
return deferred.promise;
Copy link

djom202 commented Jun 7, 2016

How does it work?. You run first protractor or gulp?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment