-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
52 lines (44 loc) · 1.31 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
'use strict';
var gulp = require('gulp');
var mocha = require('gulp-mocha');
var istanbul = require('gulp-istanbul');
var runSequence = require('run-sequence');
var eslint = require('gulp-eslint');
var path = require('path');
var fs = require('fs');
gulp.task('eslint', function() {
return gulp.src(['index.js', 'lib/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failOnError());
});
// mocha test runner
gulp.task('mochaTest', function (cb) {
gulp.src(['index.js','lib/**/*.js'])
.pipe(istanbul()) // Covering files
.pipe(istanbul.hookRequire()) // Force `require` to return covered files
.on('finish', function () {
process.chdir('./test/flexirestTest');
var app = require('./test/flexirestTest/server/server');
var serverInstance = app.start();
process.chdir('../../');
gulp.src(['test/index-test.js','test/lib/**/*-test.js'])
.pipe(mocha({ timeout: 10000 }))
.pipe(istanbul.writeReports({dir:'reports/coverage'}))// Creating the reports after tests runned
.on('end', function(){
serverInstance.close();
cb();
});
});
});
// default task
gulp.task('default', function (callback) {
runSequence(
'mochaTest',
function (error) {
if (error) {
console.log(error.message);
}
callback(error);
});
});