Closed DaAwesomeP closed 8 years ago
Does your tests read from the dist files? Because as you're not hooking the requires, then it seems to me you're just loading uninstrumented files.
For es6 support, you should look at either updating your Node version or specifying an instrumenter supporting es6
I'll close this issue as it's not a bug with the gulp-istanbul.
I'm using ES7 async/wait and ES6 module definitions (instead of CommonJS), so I can't run the tests in vanilla Node v6.7. I have to transpile to generators and CommonJS first. How can I cover the source files and test with the transpiled files?
OK, I got it to work. I guess I didn't completely understand how to cover with ES6/Babel:
const babelConfig = Object.assign(
JSON.parse(require('fs').readFileSync('.babelrc', 'utf8')),
{ stage: 0 })
gulp.task('pretest', () => {
return gulp.src('lib/**/*.js')
.pipe(sourcemaps.init())
.pipe(istanbul({
instrumenter: isparta.Instrumenter,
instrumenterOptions: {
isparta: { babel: babelConfig }
},
includeUntested: true
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('.tmp/'))
})
gulp.task('test', gulp.series('pretest', () => {
return gulp.src(['test/test-*.js'], { read: false })
.pipe(mocha({
reporter: 'spec',
globals: {
should: require('should')
}
}))
.pipe(istanbul.writeReports())
}))
I can't get istanbul to check anything. I'm using Babel and souremaps. Is this a result from running the pretest and test parts separately?
In my CI tests, I run
gulp build
in one stage, and thengulp test
later on. Here's what I get: