Closed modood closed 7 years ago
My gulpfile.js:
'use strict' const gulp = require('gulp') const mocha = require('gulp-mocha') const eslint = require('gulp-eslint') const istanbul = require('gulp-istanbul') const rootPath = ['**/*.js', '!node_modules/**', '!coverage/**'] const testPath = ['test/**/*.js'] const sourcePath = ['app/**/*.js'] gulp.task('eslint', () => gulp .src(rootPath) // attaches the lint output to the "eslint" property of the file object .pipe(eslint()) // outputs the lint results to the console .pipe(eslint.format())) gulp.task('istanbul', () => gulp .src(sourcePath) // Covering files .pipe(istanbul()) // Force `require` to return covered files .pipe(istanbul.hookRequire())) gulp.task('mocha', ['istanbul'], () => gulp .src(testPath, { read: false }) .pipe(mocha({ reporter: 'spec' })) // Creating the reports after tests ran .pipe(istanbul.writeReports()) // Enforce a coverage of at least 90% .pipe(istanbul.enforceThresholds({ thresholds: { global: 90 } }))) gulp.task('watch', () => gulp.watch(rootPath, ['eslint'])) gulp.task('test', ['eslint', 'mocha']) gulp.task('default', ['test'])
Running the following command:
./node_modules/.bin/gulp --harmony mocha
mocha is fine everything works, but Istanbul does not recognize ES6 arrow function
You need to provide an es6 compatible instrumenter https://github.com/SBoudrias/gulp-istanbul#instrumenter
My gulpfile.js:
Running the following command:
mocha is fine everything works, but Istanbul does not recognize ES6 arrow function