Skip to content

Commit

Permalink
replace browserstack tunnel with ngrok
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Nov 10, 2015
1 parent 00a91bc commit 2c67ca0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 41 deletions.
81 changes: 48 additions & 33 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ var replace = require('gulp-replace');
var webdriver = require('gulp-webdriver');
var webserver = require('gulp-webserver');
var selenium = require('selenium-standalone');
var browserStack = require('gulp-browserstack');
var ngrok = require('ngrok');
var staticTransform = require('connect-static-transform');
var privateConfig = require('./test/conf/private.conf.js').config;
var pkg = require('./package.json');
Expand Down Expand Up @@ -129,48 +129,63 @@ gulp.task('test', ['lint', 'serve', 'selenium'], function(done) {
done(error || err);
};


gulp.src('test/conf/local.conf.js')
.pipe(webdriver())
.pipe(webdriver({
baseUrl: 'http://localhost:8000'
}))
.on('error', function(err) { error = err; })
.on('finish', finish);
});

gulp.task('test:cloud', ['lint', 'serve'], function(done) {
gulp.src('test/conf/cloud.conf.js')
.pipe(browserStack.startTunnel({
key: privateConfig.key,
hosts: [{
name: 'localhost',
port: 8000,
sslFlag: 0
}]
}))
.pipe(webdriver())
.pipe(browserStack.stopTunnel())
.on('finish', function(err) {
if (server) {
try {
server.emit('kill');
} catch(e) {}
console.log('Web server stopped');
}
done(err);
ngrok.connect({
authtoken: null,
port: 8000
}, function (err, url) {
gutil.log('Tunnel started', url);
gulp.src('test/conf/cloud.conf.js')
.pipe(webdriver({
baseUrl: url
}))
.on('finish', function(err) {
if (server) {
try {
server.emit('kill');
} catch(e) {}
ngrok.disconnect();
ngrok.kill();
gutil.log('Tunnel stopped');
gutil.log('Web server stopped');
}
done(err);
});
});
});

gulp.task('test:cloud:all', ['lint', 'serve'], function(done) {
return gulp
.src('test/conf/cloud-all.conf.js')
.pipe(browserStack.startTunnel({
key: privateConfig.key,
hosts: [{
name: 'localhost',
port: 8000,
sslFlag: 0
}]
}))
.pipe(webdriver())
.pipe(browserStack.stopTunnel());
ngrok.connect({
authtoken: null,
port: 8000
}, function (err, url) {
gutil.log('Tunnel started', url);
gulp.src('test/conf/cloud-all.conf.js')
.pipe(webdriver({
baseUrl: url
}))
.on('finish', function(err) {
if (server) {
try {
server.emit('kill');
} catch(e) {}
ngrok.disconnect();
ngrok.kill();
gutil.log('Tunnel stopped');
gutil.log('Web server stopped');
}
done(err);
});
});
});

var banner = [
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"gulp-webdriver": "^1.0.1",
"gulp-webserver": "^0.9.1",
"jasmine": "^2.3.2",
"ngrok": "^0.1.99",
"run-sequence": "^1.1.4",
"selenium-standalone": "^4.7.0",
"webdriverio": "^3.2.5"
Expand Down
4 changes: 1 addition & 3 deletions test/conf/cloud-all.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var privateConfig = require('./private.conf.js').config;

var testUrl = 'http://localhost:8000/test/page/test.html',
var testUrl = '/test/page/test.html',
viewports = [[1280, 1024], [640, 480], [320, 640]];

var capabilities = [
Expand Down Expand Up @@ -145,9 +145,7 @@ var capabilities = [

for (var i = 0; i < capabilities.length; i += 1) {
var capability = capabilities[i];
capability['browserstack.local'] = true;
capability['browserstack.debug'] = true;
capability['initialBrowserUrl'] = testUrl;
capability['urls'] = capability['urls'] || [testUrl];

if (!capability['deviceOrientation']) {
Expand Down
4 changes: 1 addition & 3 deletions test/conf/cloud.conf.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var privateConfig = require('./private.conf.js').config;

var testUrl = 'http://localhost:8000/test/page/test.html',
var testUrl = '/test/page/test.html',
viewports = [[1280, 1024], [640, 480], [320, 640]];

var capabilities = [
Expand Down Expand Up @@ -39,9 +39,7 @@ var capabilities = [

for (var i = 0; i < capabilities.length; i += 1) {
var capability = capabilities[i];
capability['browserstack.local'] = true;
capability['browserstack.debug'] = true;
capability['initialBrowserUrl'] = testUrl;
capability['urls'] = capability['urls'] || [testUrl];

if (!capability['deviceOrientation']) {
Expand Down
3 changes: 1 addition & 2 deletions test/conf/local.conf.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var testUrl = 'http://localhost:8000/test/page/test.html',
var testUrl = '/test/page/test.html',
viewports = [[1280, 1024], [640, 480], [320, 640]];

var capabilities = [
Expand All @@ -21,7 +21,6 @@ var capabilities = [

for (var i = 0; i < capabilities.length; i += 1) {
var capability = capabilities[i];
capability['initialBrowserUrl'] = testUrl;
capability['urls'] = capability['urls'] || [testUrl];
capability['viewports'] = capability['viewports'] || viewports;
}
Expand Down

0 comments on commit 2c67ca0

Please sign in to comment.