forked from Lobos/react-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
60 lines (50 loc) · 1.44 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const gulp = require('gulp'),
gutil = require('gulp-util'),
rimraf = require('gulp-rimraf'),
istanbul = require('gulp-babel-istanbul'),
watch = require('gulp-watch'),
mochaPhantomJS = require('gulp-mocha-phantomjs'),
webpack = require('webpack-stream'),
config = require('./webpack.config.test'),
opts = {
includeUntested: true,
'hook-run-in-context': true,
reporters: ['text-summary', 'html'],
reportOpts: {dir: './coverage'}
},
paths = {
clean: ['./coverage', './test/static'],
src: ['./src/**/*.js'],
entry: 'test/static/testBundle.js',
tests: 'test/index.html'
};
//unit test coverage
gulp.task('clean', ()=> {
console.log('\nDeleting: ' + paths.clean);
return gulp.src(paths.clean, {read: false})
.pipe(rimraf())
.on('error', gutil.log);
});
gulp.task('build', ['clean'], ()=> {
//disable watch mode
config.watch=false;
return gulp.src('./').pipe(webpack(config)).pipe(gulp.dest('test'))
});
gulp.task('coverage',['build'], ()=> {
return gulp.src(paths.src).pipe(istanbul(opts))
.on('finish', ()=> {
gulp.src(paths.tests)
.pipe(mochaPhantomJS({reporter: 'spec'}))
.pipe(istanbul.writeReports(opts));
})
.on('error', gutil.log);
})
//unit test
gulp.task('test', ()=> {
watch(paths.entry, () => {
gulp
.src(paths.tests)
.pipe(mochaPhantomJS({reporter: 'spec'}));
});
gulp.src('./').pipe(webpack(config)).pipe(gulp.dest('test'));
});