-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
133 lines (116 loc) · 3.29 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var gulp = require('gulp');
var gutil = require('gulp-util');
var mocha = require('gulp-mocha');
var browserify = require('gulp-browserify');
var derequire = require('gulp-derequire');
var rename = require('gulp-rename');
var runSequence = require('run-sequence');
var http = require('http');
var browserstack = require('browserstack-local');
var config = require('./test/config');
gulp.task('default', ['build']);
gulp.task('build', function() {
return gulp
.src('./index.js')
.pipe(browserify({standalone: 'Universe'}))
.pipe(derequire())
.pipe(rename('universe.js'))
.pipe(gulp.dest('./build'));
});
gulp.task('test', function(callback) {
runSequence(
['build-browser-test', 'start-test-server', 'start-browserstack-local'],
'run-node-test',
'run-browser-test',
function() {
runSequence(
['stop-test-server', 'stop-browserstack-local'],
callback);
}
);
});
gulp.task('node-test', function(callback) {
runSequence(
'start-test-server',
'run-node-test',
function() {
runSequence(
'stop-test-server',
callback);
}
);
});
gulp.task('browser-test', function(callback) {
runSequence(
['build-browser-test', 'start-test-server', 'start-browserstack-local'],
'run-browser-test',
function() {
runSequence(
['stop-test-server', 'stop-browserstack-local'],
callback);
}
);
});
gulp.task('test-server', function(callback) {
runSequence(
['build-browser-test', 'start-test-server'],
callback);
});
// TASKS
gulp.task('build-browser-test', function(callback) {
runSequence(
['build-browser-unit-test', 'build-browser-functional-test'],
callback);
});
gulp.task('build-browser-unit-test', function() {
return gulp
.src('./test/test.js')
.pipe(browserify())
.pipe(gulp.dest('./test/browser'));
});
gulp.task('build-browser-functional-test', function() {
return gulp
.src('./test/tests/functional.js')
.pipe(browserify())
.pipe(gulp.dest('./test/browser'));
});
var test_server;
gulp.task('start-test-server', function(callback) {
test_server = http
.createServer(config.routes)
.listen(config.port, function() {
gutil.log('Test server started on', gutil.colors.green(config.host));
gutil.log('Run unit tests on', gutil.colors.green(config.testPage));
gutil.log('Run functional tests on', gutil.colors.green(config.functionalTestPage));
callback();
});
});
gulp.task('stop-test-server', function(callback) {
test_server.close(callback);
});
var bs_local;
gulp.task('start-browserstack-local', function(callback) {
bs_local = new browserstack.Local();
var bs_local_args = {'key': 'TODO', force: true, verbose: true};
bs_local.start(bs_local_args, function(err) {
if (!err) gutil.log('Started BrowserStackLocal');
callback(err);
});
});
gulp.task('stop-browserstack-local', function(callback) {
bs_local.stop(callback);
});
gulp.task('run-node-test', function(callback) {
gulp
.src('./test/test.js', {read: false})
.pipe(mocha())
.on('end', callback)
.on('error', function() {});
});
gulp.task('run-browser-test', function(callback) {
gulp
.src('./test/browser-test.js', {read: false})
.pipe(mocha({timeout: 60000}))
.on('end', callback)
.on('error', function() {});
});