Git Product home page Git Product logo

gulp-coverage's People

Contributors

caitp avatar dylanb avatar flacnut avatar javiercejudo avatar jhorlin avatar p3drosola avatar robinboehm avatar snyk-bot avatar thomasdezeeuw avatar wdjunaidi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

gulp-coverage's Issues

Q:Coverage template

Hi,
Curious:) Would there be any templates for coverage report?

Regards,
Denis.

Doesn't return coverage stats

Hey, this looks very handy. The problem is I'm new to Node & Gulp. I was surprised to see this has an outFile param. How can the output be piped into something? For example if I want to do something to coverage.html before I use gulp.dest to store it somewhere else. Or if I wanted to get gulp-coverage to return JSON and pipe that into something that'll fail the build if the test coverage is too low.

gulp-coverage not getting along with rewire.

My tests are failing when I use gulp-coverage and rewire __set__ method. Running mocha from terminal or just gulp-mocha seems to be working fine. This is the current configuration I have:

gulp.task('test', function () {
  gulp.src('./test/*', { read: false })
    .pipe(cover.instrument({
        pattern: ['index.js', 'src/**/*.js']
    }))
    .pipe(mocha())
    .pipe(cover.gather())
    .pipe(cover.format({
      reporter: 'html',
      outFile: 'coverage.html'
    }))
    .pipe(gulp.dest('.'))
    .pipe(exit());
});

And the error I'm getting (It applies for any var):

1) Providers should return 500 updating state on database error:
     ReferenceError: Provider is not defined
      at Object.eval (eval at __set__ (/Users/nakes/Projects/api-admin/src/handlers/provider.js:206:63), <anonymous>:1:1)
      at Object.__set__ (/Users/nakes/Projects/api-admin/src/handlers/provider.js:206:49)
      at Context.<anonymous> (/Users/nakes/Projects/api-admin/test/providers.js:87:14)
      at Test.Runnable.run (/Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runnable.js:216:15)
      at Runner.runTest (/Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:373:10)
      at /Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:451:12
      at next (/Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:298:14)
      at /Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:308:7
      at next (/Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:246:23)
      at Object._onImmediate (/Users/nakes/Projects/api-admin/node_modules/gulp-mocha/node_modules/mocha/lib/runner.js:275:5)

Any ideas?. Thanks!

Add `format` task

format task should take the JSON that is produced by the gather task and add another format to the stream. The default and first formatter will be the HTML formatter. It should be additive in that it should still be possible to use gather->format->enforce.

condition coverage

I want to get the condition coverage report, it seems that only line coverage can be reported.

cover.js - TypeError: Reduce of empty array with no initial value

/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/contrib/cover.js:519
splintered.reduce(function(p, c) {
^
TypeError: Reduce of empty array with no initial value
at Array.reduce (native)
at getSegments (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/contrib/cover.js:519:16)
at /Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/contrib/cover.js:828:28
at Array.forEach (native)
at /Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/contrib/cover.js:811:14
at Array.forEach (native)
at CoverageSession.allStats (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/contrib/cover.js:796:31)
at Transform._flush (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/index.js:76:31)
at Transform. (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:135:12)
at Transform.g (events.js:199:16)
at Transform.emit (events.js:129:20)
at finishMaybe (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:371:12)
at endWritable (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:378:3)
at Transform.Writable.end (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:356:5)
at DestroyableTransform.onend (/Users/bbigelow/work/DAW/scriptsure_platform/node_modules/gulp-jasmine/node_modules/through2/node_modules/readable-stream/lib/_stream_readable.js:523:10)
at DestroyableTransform.g (events.js:199:16)

JS Generators

Hi,

Currently code coverage for es6 generators won't work due to esprimajs not supporting them right?

Example err:

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: Line 9: Unexpected token *
    at throwError (/projects/node_modules/gulp-coverage/contrib/esprima.js:1470:21)
    at throwUnexpected (/projects/node_modules/gulp-coverage/contrib/esprima.js:1527:9)

I'm tinkering with KoaJS and was trying to test some routes which use generator functions.

Gulp task is:

  gulp.task('test', function () {
    return gulp.src(['app/**/*.spec.js'], { read: false })
      .pipe(cover.instrument({
        pattern: [
          'app/**/*.js',
          '!app/**/*.spec.js'
        ],
        debugDirectory: 'test/debug'
      }))
      .pipe(mocha())
      .pipe(cover.report({
        outFile: 'test/coverage.html'
      }));

Using mocha manually on the command line (no coverage) the tests run OK with the --harmony flag.

Have tinkered with this (no joy):

.pipe(mocha({harmony: true}))

Thanks.

Should gather() add a vinyl object to the stream ?

I was thinking of using this on a project, but I want to pipe the lcov file to coveralls, not just consume it in format() - but the object put into the stream by gather() isn't a vinyl file object. This breaks all the downstream plugins I've tried to use with it.

Any objection to me submitting a PR for this - making the thing passed between the separate plugins a vinyl object?

Any problem you would see with doing this? You've modified the lcov format, do you think it would still work with other reporting tools like coveralls?

Untested files should show up in the coverage report (and for the enforce task)

I don't have any tests for the bootstrap directory. I think the files should still show up in the coverage report (showing 0% coverage). This is very important for the enforce task, as someone could just not write any tests and pass. What are your thoughts?

'use strict';

// Load other modules
var gulp  = require( 'gulp' );
var glob  = require( 'glob' );
var mocha = require( 'gulp-mocha' );
var cover = require( 'gulp-coverage' );

// File patterns to instrument
var bootstrap   = 'bootstrap/*.js';
var controllers = 'controllers/**/*.js';
var events      = 'events/**/*.js';
var middleware  = 'middleware/**/*.js';
var models      = 'models/**/*.js';

// Test files pattern
var tests = glob.sync( 'test/**/*.js' );

gulp.task( 'default', function () {
    gulp.src( tests, { 'read' : false } )

        .pipe( cover.instrument( {
            'pattern'        : [ bootstrap, controllers, events, middleware, models ],
            'debugDirectory' : 'debug'
        } ) )

        .pipe( mocha( { } ) )

        .pipe( cover.report( {
            'outFile' : 'coverage.html'
        } ) )

        .pipe( cover.enforce() );
} );

sloc value is different from that reported by gulp-sloc due to not showing _All_ files

gulp-sloc reports this:

    physical lines : 21163

lines of source code : 16045
total comment : 2533
singleline : 1044
multiline : 1489
empty : 2585

number of files read : 65

strict mode

gulp-coverage reports this:
"sloc": 3587,
"ssoc": 6711,
"sboc": 1251,
"coverage": 37.97044884304432,
"statements": 35.2853524064968,
"blocks": 27.018385291766588,
And lists only 35 files

Why are files missing ?

FYI:
Notice that the source lists are the same
// ==========================
gulp.task('linesOfCode', function(){
gulp.src(['./../Server/source//.js'])
.pipe(sloc());
});
// ==========================
gulp.task('nodeuniter', ['clean_uniter'], function () {
var stream = gulp.src(['./testing/
.js'], {read: false})
.pipe(cover.instrument({
pattern: ['./../Server/source/
/*.js'],
debugDirectory: './.debug'
}))
.pipe(nodeunit({
reporter: 'junit',
reporterOptions: {
output: './.unitReport'
}
}))
.pipe(cover.gather())
.pipe(cover.format([{reporter: 'html'}, {reporter: 'json'}]))
.pipe(gulp.dest('./.covReport'));
return stream;
});
// ==========================

debugDirectory isn't doing anything

gulpfile.js:

    gulp.src('./index.js')
        .pipe(coverage.instrument({
            pattern: ['./test/main.js'],
            debugDirectory: 'debug'
        }))
        .pipe(mocha())
        .pipe(coverage.gather());

What happens:

  • Nothing is written to the debug directory.
  • A .coverdata directory is created. It contains an empty .cover_5097043255809695 directory.
  • A .coverrun file is created. It contains { "run" : ".cover_5097043255809695" }.

Instrument cover option

The instrument cover option seems to having some problems.

src/**/*.js doesn't work even though the src directory is present . **/src/**/*.js works, however.

The problem is that the full file path will be present in the coverage report, which is not good. I noticed you also had this issue in the screenshot.

I believe the multi globbing is not picking up the right base dir.

Doesn't work with native node modules such as crypto. TypeError: Object.defineProperty called on non-object

TypeError: Object.defineProperty called on non-object
      at Function.defineProperty (native)
      at __intro_MDZac7 (/xxx/src/main.js:24:41)
      at Object.randomString (/xxx/src/main.js:95:64)
      at Context.<anonymous> (/xxx/test/main.js:11:16)
      at callFn (/xxx/node_modules/mocha/lib/runnable.js:223:21)
      at Test.Runnable.run (/xxx/node_modules/mocha/lib/runnable.js:216:7)
      at Runner.runTest (/xxx/node_modules/mocha/lib/runner.js:374:10)
      at /xxx/node_modules/mocha/lib/runner.js:452:12
      at next (/xxx/node_modules/mocha/lib/runner.js:299:14)
      at /xxx/node_modules/mocha/lib/runner.js:309:7

The relevant code is:

var crypto = require('crypto');

var self = {};

var bytesMapper = {
    ascii: 1,
    utf8: 2,
    utf16le: 4,
    ucs2: 8,
    base64: 1.5,
    binary: 0.25,
    hex: 0.5
};

self.randomString = function randomString(length, encoding) {
    encoding = encoding || 'ascii';

    var buf = crypto.pseudoRandomBytes(length * bytesMapper[encoding] * 2);
    return buf.toString(encoding).substr(0, length);
};

module.exports = self;

Here is the instrumented code:

// Instrumentation Header
{
    var fs = require('fs');
    var __statement_Y9dYKY, __expression_s_b1xL, __block_QpunSS;
    var store = require('/xxx/node_modules/gulp-coverage/contrib/coverage_store.js');

    __statement_Y9dYKY = function(i) {
        var fd = store.register('/xxx/src/main.js');
        fs.writeSync(fd, '{"statement": {"node": ' + i + '}},\n');
    }; 

    __expression_s_b1xL = function(i) {
        var fd = store.register('/xxx/src/main.js');
        fs.writeSync(fd, '{"expression": {"node": ' + i + '}},\n');
    }; 

    __block_QpunSS = function(i) {
        var fd = store.register('/xxx/src/main.js');
        fs.writeSync(fd, '{"block": ' + i + '},\n');
    }; 
    __intro_MDZac7 = function(id, obj) {
        // console.log('__intro: ', id, ', obj.__instrumented_miss: ', obj.__instrumented_miss, ', obj.length: ', obj.length);
        Object.defineProperty && Object.defineProperty(obj, '__instrumented_miss', {enumerable: false, writable: true});
        obj.__instrumented_miss = obj.__instrumented_miss || [];
        if ('undefined' !== typeof obj && null !== obj && 'undefined' !== typeof obj.__instrumented_miss) {
            if (obj.length === 0) {
                // console.log('interim miss: ', id);
                obj.__instrumented_miss[id] = true;
            } else {
                obj.__instrumented_miss[id] = false;
            }
        }
        return obj;
    };
    function isProbablyChainable(obj, id) {
        return obj &&
            obj.__instrumented_miss[id] !== undefined &&
            'number' === typeof obj.length;
    }
    __extro_japAko = function(id, obj) {
        var fd = store.register('/xxx/src/main.js');
        // console.log('__extro: ', id, ', obj.__instrumented_miss: ', obj.__instrumented_miss, ', obj.length: ', obj.length);
        if ('undefined' !== typeof obj && null !== obj && 'undefined' !== typeof obj.__instrumented_miss) {
            if (isProbablyChainable(obj, id) && obj.length === 0 && obj.__instrumented_miss[id]) {
                // if the call was not a "constructor" - i.e. it did not add things to the chainable
                // and it did not return anything from the chainable, it is a miss
                // console.log('miss: ', id);
            } else {
                fs.writeSync(fd, '{"chain": {"node": ' + id + '}},\n');
            }
            obj.__instrumented_miss[id] = undefined;
        } else {
            fs.writeSync(fd, '{"chain": {"node": ' + id + '}},\n');
        }
        return obj;
    };
};
////////////////////////

// Instrumented Code
(function () {
    {
        __statement_Y9dYKY(0);
        var crypto = (__expression_s_b1xL(1), require('crypto'));
    }
    {
        __statement_Y9dYKY(2);
        var self = {};
    }
    {
        __statement_Y9dYKY(3);
        var bytesMapper = {
                ascii: 1,
                utf8: 2,
                utf16le: 4,
                ucs2: 8,
                base64: 1.5,
                binary: 0.25,
                hex: 0.5
            };
    }
    {
        __statement_Y9dYKY(4);
        self.randomString = function randomString(length, encoding) {
            __block_QpunSS(0);
            {
                __statement_Y9dYKY(5);
                encoding = (__expression_s_b1xL(6), (__expression_s_b1xL(7), encoding) || 'ascii');
            }
            {
                __statement_Y9dYKY(8);
                var buf = __extro_japAko(9, __intro_MDZac7(9, crypto).pseudoRandomBytes((__expression_s_b1xL(10), (__expression_s_b1xL(11), (__expression_s_b1xL(12), length) * bytesMapper[encoding]) * 2)));
            }
            return __expression_s_b1xL(13), __extro_japAko(14, __intro_MDZac7(14, __extro_japAko(15, __intro_MDZac7(15, buf).toString(encoding))).substr(0, length));
        };
    }
    {
        __statement_Y9dYKY(16);
        module.exports = self;
    }
}());

Coffeescript Support

I try to load coffeescript to cover but it seems not work.
Will it support coffeescript?

Unable to ignore lines of code with `//#JSCOVERAGE_IF`

I've been unable to ignore certain lines of code, as stated on the JSCoverage docs. I'm doing something like on the following snippet:

//#JSCOVERAGE_IF
if (!module.parent) {
  server.start(function () {
    server.log('info', 'Server running at: ' + server.info.uri);
  });
}

Same applies enclosing the code using the form //#JSCOVERAGE_IF 0, //#JSCOVERAGE_ENDIF.

Is this currently supported or am I doing something wrong?

Thanks!

Not working on Windows

Ok, this is working great for me on Mac / Linux but not Windows. It seems the stats aren't being gathered. enforce doesn't fail when it should and report isn't showing any code or stats.

I know this isn't a problem with a missing dependency or something like that because it's being tested with Travis. See build #9 where I set each of the enforce options to 100 to deliberately fail the build.

I just tried pulling the latest revision of this project (from GitHub) and running the tests. I got this:

stream.js:94
    throw er; // Unhandled stream error in pipe.
          ^
TypeError: Cannot call method 'stats' of undefined
    at Suite.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:95:50)
    at context.describe.context.context (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\interfaces\bdd.js:73:10)
    at Suite.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:87:5)
    at context.describe.context.context (C:\Users\Digital\Code\GitHub\gulp-coverage\node_modules\gulp-mocha\node_modules\mocha\lib\interfaces\bdd.js:73:10)
    at Object.<anonymous> (C:\Users\Digital\Code\GitHub\gulp-coverage\test\cover.js:23:1)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
npm ERR! weird error 8
npm ERR! not ok code 0

Lines missing from coverage report

I would be happy to investigate this and see if I can find the issue but I wasn't sure if I was just implementing this incorrectly.

Here's the html coverage report for my chromewut extension: https://rawgit.com/natedsaint/chromewut/master/reports/coverage.html

As you can see, each class looks good except that the line that contains the method definitions after the first one appear to be cut off. I'm not sure if it's that my code is formatted in such a way it doesn't know how to generate the report, or if there's a config I'm missing, or it's simply a bug.

Let me know if I can be of any assistance.

0% line coverage, 0% statement coverage, 0% block coverage, 0 SLOC...?

I have been unable to successfully generate code coverage for my nodejs test code and wondered if there may be in issue with either the version of gulp-jasmine or some other dependency I am using?

The gulp task I am running looks like this:

gulp.task('server-unit-tests', function () {
    return gulp.src('./server/**/*.js', { read: false })
        .pipe(cover.instrument({
            pattern: ['./server/test/**/*.spec.js']
        }))
        .pipe(jasmine({
            verbose: true,
            includeStackTrace: true
        }))
        .pipe(cover.gather())
        .pipe(cover.format([
            { reporter: 'html', outFile: 'coverage.html' },
            { reporter: 'json', outFile: 'coverage.json' }
        ]))
        .pipe(gulp.dest('./server/coverage'));
});

This generates the following .json file:

{
 "files": [],
 "sloc": 0,
 "ssoc": 0,
 "sboc": 0,
 "coverage": null,
 "statements": null,
 "blocks": null,
 "uncovered": [
  "server/test/config.spec.js",
  "server/test/utils/cypher-promise.spec.js"
 ]
}

The html output looks like:
screenshot 2014-10-06 22 13 26

I originally thought it maybe due to a different version of one of the libraries but when I checked out the latest code from here and when I run gulp on gulp-coverage I always see one of the jasmine test showing as 0% coverage and wondered if this could be related?

screenshot 2014-10-06 22 15 57

My package versions:

{
    "gulp": "^3.8.8",
    "gulp-coverage": "^0.3.31",
    "gulp-jasmine": "^1.0.0"
}

Have I missed something obvious?

Update depenendencies for vulnerability fixes

Running npm audit against latest package version reveals several problems which likely need dependency updates in this library.

First and foremost is the fact that this package still relies on jade rather modern pug replacement. There are 5 vulnerabilities related to this package alone.

Second, an update should be made to multimatch to get latest version which would eliminate underlying lodash vulnerabilities as multimatch no longer uses this package as dependency.

This would leave only a single remaining vulnerability exposed by the multimatch library for which I have already opened an issue - sindresorhus/multimatch#26

build fails because debugDirectory cannot be created

The code which creates the debugDirectory only checks if the directory does not exist, it does not check or create any parent directories and thus fails.

Steps to reproduce the issue:

  • set cover.instrument options: debugDirectory : "foo/bar/spam"
  • run gulp

The problem is near the fs.mkdirSync() calls in contrib/covers.js.
A simple solution would be to use a function which ensures all parent directories are created:

e.g.

function mkdirs(path){
    var dirs = path.split('/');

    for(var i=1,l=dirs.length; i<=l; i++){
        path = dirs.slice(0, i).join('/');

        if (! fs.existsSync(path) ) {
            fs.mkdirSync(path);
        }
    }
}

Various warnings generated when installing from npm

Paraphrasing:

jade has been renamed to pug, please install the latest version of pug instead of jade
mini match: please update to minimatch 3.0.2 or higher to avoid a regexp DoS issue
Jade => transformers: deprecated, use jstransformer

Is there a way to turn these off, or update the package to new versions that fix these problems?

Error: Received a non-Vinyl object in `dest()`

This gulpfile:

gulp = require('gulp');
mocha = require('gulp-mocha');
cover = require('gulp-coverage');

gulp.task('test', function () {
    return gulp.src('test/**/*.js', { read: false })
            .pipe(cover.instrument({
                pattern: ['src/**/*.js'],
                debugDirectory: 'debug'
            }))
            .pipe(mocha())
            .pipe(cover.gather())
            .pipe(cover.format({reporter: 'html'}))
            .pipe(gulp.dest('reports'));
});

When I run gulp test I get

[email protected])                                                                 
λ gulp test                                                                   
[20:44:16] Using gulpfile ~\Documents\GitHub\node-cognitive-services\gulpfile.
js                                                                            
[20:44:16] Starting 'test'...                                                 
                                                                              
                                                                              
  API Test                                                                    
    √ should throw an error if a body parameter is required for json and not p
resent                                                                        
    √ should throw an error if the boolean body parameter has a value other th
an true or false                                                              
    √ should throw an error if a body parameter is required and its value is n
ot in the list of options                                                     
    √ should throw an error if a parameter is required and not present        
    √ should throw an error if more than one parameter is required but not pre
sent                                                                          
    √ should throw an error if a parameter is required and its value is not in
 the list of options                                                          
    √ should accept a list of options for parameters                          
    √ should throw an error if the boolean parameter has a value other than tr
ue or false                                                                   
    √ should not throw an error if the endpoint is supported                  
    √ should throw an error if the endpoint is not supported                  
    √ should throw an error if a header is required but not present           
    √ should throw an error if more than one headers are required but not pres
ent                                                                           
                                                                              
                                                                              
  12 passing (8ms)                                                            
                                                                              
[20:44:19] 'test' errored after 3.06 s                                        
[20:44:19] Error: Received a non-Vinyl object in `dest()`                     
    at DestroyableTransform.normalize [as _transform] (C:\Users\mparn\Document
s\GitHub\node-cognitive-services\node_modules\vinyl-fs\lib\dest\prepare.js:16:
17)                                                                           
    at DestroyableTransform.Transform._read (C:\Users\mparn\Documents\GitHub\n
ode-cognitive-services\node_modules\readable-stream\lib\_stream_transform.js:1
82:10)                                                                        
    at DestroyableTransform.Transform._write (C:\Users\mparn\Documents\GitHub\
node-cognitive-services\node_modules\readable-stream\lib\_stream_transform.js:
170:83)                                                                       
    at doWrite (C:\Users\mparn\Documents\GitHub\node-cognitive-services\node_m
odules\readable-stream\lib\_stream_writable.js:406:64)                        
    at writeOrBuffer (C:\Users\mparn\Documents\GitHub\node-cognitive-services\
node_modules\readable-stream\lib\_stream_writable.js:395:5)                   
    at DestroyableTransform.Writable.write (C:\Users\mparn\Documents\GitHub\no
de-cognitive-services\node_modules\readable-stream\lib\_stream_writable.js:322
:11)                                                                          
    at Pumpify.Duplexify._write (C:\Users\mparn\Documents\GitHub\node-cognitiv
e-services\node_modules\duplexify\index.js:208:22)                            
    at doWrite (C:\Users\mparn\Documents\GitHub\node-cognitive-services\node_m
odules\readable-stream\lib\_stream_writable.js:406:64)                        
    at writeOrBuffer (C:\Users\mparn\Documents\GitHub\node-cognitive-services\
node_modules\readable-stream\lib\_stream_writable.js:395:5)                   
    at Pumpify.Writable.write (C:\Users\mparn\Documents\GitHub\node-cognitive-
services\node_modules\readable-stream\lib\_stream_writable.js:322:11)         
                                                                              

Any ideas on how to fix this?

output summary as text

How can I output a summary of coverage as text? Preferably, I'd like to pass the json output to a function so that I can pick the parts I want and console.log them. I tried playing with format/report but I was not able to. Am I missing something?

Error in plugin 'gulp-coveralls' Message: Failed to parse string

I am getting the following error when I try to run gulp in Travis CI;

[17:27:22] Starting 'coveralls'...
[error] "2016-01-15T17:27:23.420Z" 'error from lcovParse: ' 'Failed to parse string'
[error] "2016-01-15T17:27:23.421Z" 'input: ' ''
[17:27:23] 'coveralls' errored after 529 ms
[17:27:23] Error in plugin 'gulp-coveralls'
Message:
Failed to parse string
[17:27:27] Finished 'static' after 5.94 s
npm ERR! Test failed. See above for more details.
The command "npm test" exited with 1.

It runs without incident locally, but it fails to run in Travis CI. What am I doing wrong?

TypeError: Reduce of empty array with no initial value

I received the following error after making this change. Coverage worked fine before than.

PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/contrib/cover.js:660
    interim.reduce(function(p, c) {
            ^
TypeError: Reduce of empty array with no initial value
    at Array.reduce (native)
    at linesWithData (PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/contrib/cover.js:660:13)
    at PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/contrib/cover.js:770:21
    at Array.forEach (native)
    at CoverageSession.allStats (PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/contrib/cover.js:758:31)
    at Transform._flush (PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/index.js:76:31)
    at Transform.<anonymous> (PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:135:12)
    at Transform.g (events.js:180:16)
    at Transform.emit (events.js:92:17)
    at finishMaybe (PROJECT_DIR/backbone/kinView/node_modules/gulp-coverage/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:371:12)

Emit raw LCOV too

I'd like to be able to wire this up with https://www.npmjs.org/package/gulp-coveralls (or something else that reports to coveralls), but that consumes the raw LCOV data; not the JSON-formatted output

Ideally:
gulp.task('test:unit', function() {
return gulp.src('test//*.js')
.pipe(coverage.instrument({pattern: ['lib/
/*.js']}))
.pipe(mocha())
.pipe(coverage.gather())
.pipe(coverage.format({reporter: 'lcov'}))
.pipe(coveralls());
});

Coverage tests hangs up

gulp-coverage unable to create the coverage.html reporter file and my coverage test hangs up. I am using mocha as test runner. Below is my gulpfile.js:

gulp.src( tests, { 'read' : false } )

        .pipe( cover.instrument( {
            'pattern'        : [ handlers, services ],
            'debugDirectory' : 'instrumented'
        } ) )

        .pipe( mocha( options ) )

        .pipe( cover.gather() )

        .pipe( cover.format( {
            'reporter' : 'html',
            'outFile'  : 'coverage.html'
        } ) )

        .pipe( cover.enforce( {
            'statements' : 70,
            'blocks'     : 70,
            'lines'      : 70
        } ) )

        .once( 'error', function () {
            process.exit( 1 );
        } )

        .once( 'end', function () {
            process.exit();
        } );

format task does not actually work with gulp.dest()

With [email protected] / [email protected] / [email protected]

Currently, piping format() to gulp.dest() will fail because there is no relative property specified when writing to the stream.

It's entirely possible that I'm doing something wrong here because my gulp-fu isn't the strongest, but I find it more likely that something in gulp has changed recently which broke this, because this happens frequently with gulp and it's a source of massive frustration for everyone who ever uses it.

But yeah, we're going to want to output ~lcov-ish files to json, and to do that we are going to want to use the format() tool, but maybe report() will be a suitable workaround for now

Unexpected reserved word: `class`

I'm using gulp-coverage in my gulpfile like so:

gulp.task('test', () => {
  return gulp.src('test/**/*.js', {read: false})
    .pipe(cover.instrument({
      pattern: [`${srcDir}/**/*.js`, `!${srcDir}/configure.js`],
      debugDirectory: 'debug',
    }))
    .pipe(mocha({reporter: 'nyan'}))
    .pipe(cover.gather())
    .pipe(cover.format())
    .pipe(gulp.dest('reports'));
});

This the error I'm getting when running the task:

c:\Users\ketsu\Documents\Development\plexacious>gulp test
(node:14780) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
[23:57:50] Using gulpfile c:\Users\ketsu\Documents\Development\plexacious\gulpfile.js
[23:57:50] Starting 'test'...

events.js:160
      throw er; // Unhandled 'error' event
      ^
 Error: Line 23: Unexpected reserved word
    at throwError (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1470:21)
    at throwUnexpected (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1518:17)
    at parsePrimaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1832:16)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at trackLeftHandSideExpressionAllowCall (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3483:61)
    at parsePostfixExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:1938:20)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at parseUnaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:2001:16)
    at c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:3577:38
    at parseBinaryExpression (c:\Users\ketsu\Documents\Development\plexacious\node_modules\instrumentjs\esprima.js:2103:16)

In my source code file, line 23 is

class Plexacious extends EventEmitter {

If I replace this with a function declaration, the file seems to parse that line correctly. If I only remove the extends portion, I get the same error, so it seems that it's the class keyword itself that's causing the error.

Adding // cover: false to the end of the line does not help.

gulp-coverage version 0.3.38
instrumentjs version 0.0.2 is the one installed as a dependency of gulp-coverage, but I still get the same error after manually updating to 0.0.3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.