-
Notifications
You must be signed in to change notification settings - Fork 12
/
Gulpfile.js
170 lines (142 loc) · 4.34 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
var path = require('path');
var del = require('del');
var gulp = require('gulp');
var babel = require('gulp-babel');
var eslint = require('gulp-eslint');
var webmake = require('gulp-webmake');
var merge = require('merge-stream');
var listBrowsers = require('testcafe-browser-tools').getInstallations;
gulp.task('clean', function (cb) {
del('lib', cb);
});
gulp.task('copy-vendor', ['clean'], function () {
gulp
.src('vendor/**/*.*')
.pipe(gulp.dest('lib/vendor'));
});
gulp.task('build', ['lint', 'copy-vendor'], function () {
var js = gulp
.src(['src/**/*.js', '!src/**/*.mustache.js'])
.pipe(babel());
var templates = gulp
.src('src/**/*.mustache');
var jsTemplates = gulp
.src('src/**/*.mustache.js')
.pipe(webmake());
return merge(js, templates, jsTemplates)
.pipe(gulp.dest('lib'));
});
gulp.task('lint', function () {
return gulp
.src([
'src/**/*.js',
'test/**/*.js',
'Gulpfile.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test', ['build'], function () {
require('./test/index');
});
gulp.task('saucelabs', ['lint', 'build'], function (done) {
var BROWSERS = [
{
platform: 'Windows 10',
browserName: 'microsoftedge'
},
{
platform: 'Windows 10',
browserName: 'chrome'
},
{
platform: 'Windows 10',
browserName: 'firefox'
},
{
platform: 'Windows 10',
browserName: 'internet explorer',
version: '11.0'
},
{
platform: 'OS X 10.12',
browserName: 'safari',
version: '11.0'
},
{
platform: 'Linux',
browserName: 'android',
version: '5.1',
deviceName: 'Android Emulator'
},
{
platform: 'iOS',
browserName: 'Safari',
version: '10.3',
deviceName: 'iPhone 7 Plus Simulator'
}
];
var sauceLabsSettings = {
username: process.env.SAUCELABS_USERNAME,
accessKey: process.env.SAUCELABS_ACCESS_KEY,
build: process.env.TRAVIS_JOB_ID || 'build',
tags: [process.env.TRAVIS_BRANCH || 'master'],
browsers: BROWSERS,
name: 'qunit-harness qunit tests',
timeout: 60
};
var tests = ['/test1-test.js', '/test2-test/index-test.js', '/dir1/test3-test.js']
.map(function (item) {
return path.join(__dirname, '/test/tests/fixtures', item)
});
var afterCallbackCalled = false;
var after = function () {
afterCallbackCalled = true;
};
var server = require('./test/index');
function testsDone (err) {
server.close();
if (!err && !afterCallbackCalled)
err = 'after callback was not called';
done(err);
}
server
.saucelabs(sauceLabsSettings)
.tests(tests)
.after(after)
.run()
.then(testsDone)
.catch(testsDone);
});
gulp.task('cli', ['lint', 'build'], function (done) {
listBrowsers().then(function (browsers) {
var targetBrowsers = [
{ browserInfo: browsers['chrome'], browserName: 'chrome' },
{ browserInfo: browsers['firefox'], browserName: 'firefox' }
];
var cliSettings = { browsers: targetBrowsers, timeout: 60 };
var tests = ['/test1-test.js', '/test2-test/index-test.js', '/dir1/test3-test.js']
.map(function (item) {
return path.join(__dirname, '/test/tests/fixtures', item)
});
var afterCallbackCalled = false;
var after = function () {
afterCallbackCalled = true;
};
var server = require('./test/index');
function testsDone (err) {
server.close();
if (!err && !afterCallbackCalled)
err = 'after callback was not called';
done(err);
}
server
.cli(cliSettings)
.tests(tests)
.after(after)
.run()
.then(testsDone)
.catch(testsDone);
});
});