dylanb / gulp-coverage

Gulp coverage reporting for Node.js that is independent of the test runner
MIT License
60 stars 12 forks source link

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

Open miparnisari opened 4 years ago

miparnisari commented 4 years ago

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

rvices@1.2.3)                                                                 
λ 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?

VarCharMax commented 3 years ago

I've been trying for two days to get this library to work. I think we have to assume it is currently broken, since no issues seem to be getting resolved despite them having been reported months ago.

If I do this:

.pipe(mocha())
    .pipe(
      cover.report({
        reporter: "json",
        outFile: "testoutput.json",
      })
    );

at least it doesn't crash. But the result set seems to be empty. Also, they seem to indicate in the documention that the report action is deprecated, so that doesn't say much.

As users have noted in other issues, when you install it you get tons of warnings about deprecated libraries, so that doesn't augur well. It's a pity, because I was originally trying to use the Istanbul library, only to be told that it was out-of-date, and this was the latest thing.

VarCharMax commented 3 years ago

I gave up on gulp-coverage and went back the the nyc library, which is where I started. I had some success with this:

gulp.task(
  "coverage",
  shell.task(["npx cross-env NODE_ENV=test nyc mocha test/**/*.js"])
);

I had to install the cross-env module. I at least get a print-out, but I haven't sorted out issues like instrumentation.

I can't see any way to use the nyc library in a fluent manner, so perhaps there isn't any. Also, I need to stop using the gulp.task syntax because it's obsolete.