-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtests.js
More file actions
74 lines (71 loc) · 1.87 KB
/
tests.js
File metadata and controls
74 lines (71 loc) · 1.87 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* eslint-disable no-var, strict, prefer-arrow-callback */
'use strict';
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var mocha = require('gulp-mocha');
var cover = require('gulp-coverage');
var coveralls = require('gulp-coveralls');
var config = require('./config');
module.exports = {
lint: function () {
return gulp.src(config.sources)
.pipe(eslint({
extends: 'eslint:recommended',
rules: {
strict: 2
},
env: {
node: true,
browser: true
}
}))
.pipe(eslint.format())
.pipe(eslint.failAfterError());
},
specs: function (done) {
var prependToAll = function(path, globs) {
var ret = [];
for (var i = 0; i < globs.length; i++) {
var value = globs[i];
ret.push(path + '/' + value);
}
return ret;
};
var fs = require('fs');
var target = config.target;
if (!fs.existsSync(target)) {
fs.mkdirSync(target);
}
var pwd = process.cwd();
process.chdir(target);
var testSrc = prependToAll('..', config.testSources);
var src = prependToAll('..', config.sources);
var stream = gulp.src(testSrc, { read: false })
.pipe(cover.instrument({
pattern: src
}))
.pipe(mocha())
.pipe(cover.gather());
if (process.env.TRAVIS == 'true') {
stream = stream.pipe(cover.format([
{ reporter: 'lcov' }
]))
.pipe(coveralls());
} else {
stream = stream.pipe(cover.format([
{ reporter: 'html' },
{ reporter: 'json' },
{ reporter: 'lcov' }
]))
.pipe(gulp.dest('reports'));
}
return stream.pipe(cover.enforce({
statements: config.ceverageMin,
blocks: config.ceverageMin,
lines: config.ceverageMin,
}))
.on('end', function() {
process.chdir(pwd);
});
}
};