Closed jamesmorgan closed 10 years ago
Yes, you have your tests and your source code switched around in the task.
The gulp.src('/mytests/**.js')
line should match the test files. So in your case, I would expect it to have the following glob './server/test/**/*.spec.js'
(that is unless you have named your test directory illogically.
The cover.instrument
line should contain a glob that matches the files with the functionality that you want to ensure is covered by your tests. I don't know what this should be in your case but it is not what you have supplied.
I hope this helps
Yes you are correct, sorry I was confused.
This is the config which gives me coverage :+1:
gulp.task('server-unit-tests', function () {
return gulp.src('./server/test/**/*.spec.js')
.pipe(cover.instrument({
pattern: ['./server/src/**/*.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'));
});
I have the same problem with this code: https://github.com/miparnisari/node-cognitive-services/tree/fixes
Any ideas? Here is my gulpfile:
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var cover = require('gulp-coverage');
gulp.task('test', () => {
return gulp.src('test/*.js')
.pipe(cover.instrument({
pattern: ['index.js', 'api/*.js', 'lib/*.js'],
debugDirectory: 'debug'
}))
.pipe(mocha({
timeout: 15000
}))
.pipe(cover.gather())
.pipe(cover.format([
{ reporter: 'html', outFile: 'coverage.html' },
{ reporter: 'json', outFile: 'coverage.json' }
]))
.pipe(gulp.dest('reports'));
});
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:
This generates the following
.json
file:The
html
output looks like: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
ongulp-coverage
I always see one of the jasmine test showing as 0% coverage and wondered if this could be related?My package versions:
Have I missed something obvious?