Permalink
Browse files

Example for BrowerStack showing tunneling isn't working.

  • Loading branch information...
1 parent 9704344 commit 677e22d9347de2c7d1eea4645019608d380806ed @airportyh airportyh committed Nov 26, 2012
View
@@ -3,4 +3,5 @@
testem.log2
/tests/data
*.log
-tunnel
+tunnel
+node_modules
@@ -0,0 +1,21 @@
+<!doctype html>
+<html>
+<head>
+<title>Test Page</title>
+<script src="jquery.js"></script>
+<script>
+$(function(){
+ $.ajax({
+ url: '/api',
+ success: function(data){
+ console.log(data)
+ $.post('/api', {num: Number(data) + 1})
+ }
+ })
+})
+</script>
+</head>
+<body>
+<h1>Test Page</h1>
+</body>
+</html>

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,26 @@
+var express = require('express')
+var app = express()
+
+app.use(express.bodyParser())
+
+app.get('/', function(req, resp){
+ resp.sendfile('index.html')
+})
+
+app.get('/jquery.js', function(req, resp){
+ resp.sendfile('jquery.js')
+})
+
+app.get('/api', function(req, resp){
+ var num = Math.round(Math.random() * 10)
+ console.log('GET /api ' + num)
+ resp.end(String(num))
+})
+
+app.post('/api', function(req, resp){
+ var num = req.body['num']
+ console.log('POST /api ' + num)
+ resp.end('')
+})
+
+app.listen(7357)
@@ -1,5 +1,5 @@
{
- "on_start": "forward 7357",
+ "test_page": "index.html",
"launchers": {
"BrowserStackFirefox": {
"command": "browserstack launch firefox:17.0 http://localhost:7357 --attach",
View
@@ -2,6 +2,7 @@ var EventEmitter = require('events').EventEmitter
var Backbone = require('backbone')
var BrowserRunner = require('./runners').BrowserRunner
var exec = require('child_process').exec
+var spawn = require('child_process').spawn
var log = require('winston')
function BaseApp(config){
@@ -20,12 +21,6 @@ function BaseApp(config){
self.emit('all-runners-complete')
}
})
-
- var on_start = this.config.get('on_start')
- if (on_start){
- log.info('Starting on_start hook ' + on_start)
- this.onStartProcess = exec(on_start)
- }
}
BaseApp.prototype = {
__proto__: EventEmitter.prototype
@@ -35,6 +30,28 @@ BaseApp.prototype = {
, runPostprocessors: function(callback){
this.runHook('after_tests', callback)
}
+ , startOnStartHook: function(){
+ var on_start = this.config.get('on_start')
+ if (on_start){
+ log.info('Starting on_start hook ' + on_start)
+ try{
+ this.onStartProcess = spawn('/usr/local/bin/forward', [7357])
+ this.onStartProcess.stdout.on('data', function(data){
+ log.info(on_start + ': ' + data)
+ })
+ this.onStartProcess.stderr.on('data', function(data){
+ log.info(on_start + ': ' + data)
+ })
+ this.onStartProcess.on('exit', function(){
+ log.info(on_start + ' exited')
+ })
+ log.info('done starting ' + on_start)
+ }catch(e){
+ log.error(e.message)
+ log.error(e.stack)
+ }
+ }
+ }
, runExitHook: function (callback) {
if(this.onStartProcess) {
this.onStartProcess.kill('SIGTERM');
View
@@ -30,6 +30,9 @@ function App(config){
config.getLaunchers(this, function(launchers){
self.launchers = launchers
self.initialize()
+ self.server.once('server-start', function(){
+ self.startOnStartHook()
+ })
})
}
View
@@ -37,9 +37,12 @@ function App(config){
with(this.server){
on('server-start', this.initView.bind(this))
on('file-requested', this.onFileRequested.bind(this))
+ once('server-start', this.startOnStartHook.bind(this))
}
this.server.start()
+
})
+
}
App.prototype = {

0 comments on commit 677e22d

Please sign in to comment.