Skip to content

Commit 4005f31

Browse files
authored
Build: include browser tests in travis-ci (#74)
1 parent fe492e8 commit 4005f31

File tree

3 files changed

+54
-17
lines changed

3 files changed

+54
-17
lines changed

.travis.yml

+22-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
language: node_js
2-
node_js:
3-
- '0.10'
4-
- '0.12'
5-
- 'iojs'
6-
- '4'
7-
- '5'
8-
- '6'
9-
102
addons:
113
apt:
124
sources:
13-
- ubuntu-toolchain-r-test
5+
- ubuntu-toolchain-r-test
146
packages:
15-
- g++-4.8
7+
- g++-4.8
8+
node_js:
9+
- '0.10'
10+
- '0.12'
11+
- iojs
12+
- '4'
13+
- '5'
14+
- '6'
1615
env:
1716
matrix:
17+
- CXX=g++-4.8 TASKS=test:nodejs
18+
matrix:
19+
include:
20+
- node_js: 6
1821
env:
19-
- TASKS=test:nodejs
20-
- EXTRAS=""
21-
global:
22-
- CXX=g++-4.8
23-
22+
- CXX=g++-4.8 TASKS=travis:browser
23+
addons:
24+
firefox: latest
25+
sauce_connect: true
26+
before_script:
27+
- "export DISPLAY=:99.0"
28+
- "sh -e /etc/init.d/xvfb start"
29+
- sleep 5 # give xvfb some time to start
2430
script:
25-
- ./node_modules/.bin/gulp $TASKS $EXTRAS
31+
- ./node_modules/.bin/gulp $TASKS

gulpfile.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ var ARGV = require("yargs").
2828
var webpack = require("webpack-stream"),
2929
clone = require("lodash.clone"),
3030
gulp = require("gulp"),
31+
gutil = require("gulp-util"),
3132
karma = require("karma"),
3233
merge = require("lodash.merge"),
3334
mocha = require("gulp-mocha"),
@@ -168,7 +169,10 @@ var KARMA_CONFIG = {
168169
loader: "json"
169170
}
170171
]
171-
}
172+
},
173+
},
174+
webpackMiddleware: {
175+
noInfo: true
172176
},
173177
reporters: ["mocha"],
174178
customLaunchers: {
@@ -293,6 +297,32 @@ gulp.task("test:browser", function(cb) {
293297
cb);
294298
});
295299

300+
// ## TRAVIS-CI TASKS ###
301+
gulp.task("travis:browser", function(cb) {
302+
if ("true" !== process.env.TRAVIS) {
303+
gutil.log("travis-ci environment not detected");
304+
cb();
305+
return;
306+
}
307+
308+
gutil.log("pull request: ", process.env.TRAVIS_PULL_REQUEST);
309+
gutil.log("job number: ", process.env.TRAVIS_JOB_NUMBER);
310+
if (process.env.SAUCE_USERNAME &&
311+
process.env.SAUCE_ACCESS_KEY &&
312+
"false" === process.env.TRAVIS_PULL_REQUEST) {
313+
ARGV.sauce = true;
314+
merge(KARMA_CONFIG.sauceLabs, {
315+
startConnect: false,
316+
tunnelIdentifier: process.env.TRAVIS_JOB_NUMBER || null
317+
});
318+
} else {
319+
ARGV.sauce = false;
320+
ARGV.browsers="Firefox";
321+
}
322+
323+
runSequence("test:browser", cb);
324+
});
325+
296326
// ### MAIN TASKS ###
297327
gulp.task("test", function(cb) {
298328
runSequence("test:lint",

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"gulp-mocha": "^2.0.0",
5555
"gulp-rename": "^1.2.0",
5656
"gulp-uglify": "^1.1.0",
57+
"gulp-util": "^3.0.7",
5758
"istanbul": "^0.4.0",
5859
"jose-cookbook": "git+https://github.com/ietf-jose/cookbook.git",
5960
"json-loader": "^0.5.4",

0 commit comments

Comments
 (0)