-
Notifications
You must be signed in to change notification settings - Fork 50.8k
Make it easy to run the browser tests on saucelabs #510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
benjamn
merged 20 commits into
facebook:master
from
subtleGradient:subtlegradient/run-the-browser-tests-on-saucelabs
Nov 14, 2013
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
0401a0a
NEW sauce-tunnel grunt task
subtleGradient ff857ef
desiredCapabilities webdriver config
subtleGradient 6b1042a
fixup sauce-tunnel
subtleGradient 7ee3055
ignore tunnel logs
subtleGradient f12c428
NEW saucelabs webdriver task
subtleGradient 7c8b70e
better error handling for jasmine task
subtleGradient 66a0f2e
Suppress encoding warning in Firefox
subtleGradient e3ced21
postDataToURL using ajax instead of DOM
subtleGradient 39ba5f9
no need to pass jasmine through jsx
subtleGradient 37bb9b7
remove old browser logger
subtleGradient b845134
user JSON encoding for browser logger
subtleGradient d9b7e47
sped up the webdriver tests
subtleGradient cd24cbd
name local saucelabs tests too
subtleGradient c1925db
cleanup
subtleGradient 4daeda1
log individual test results when in --debug mode
subtleGradient 2d6eb3d
don't log your password to the console
subtleGradient 08bd1f9
wait a little longer for the page to load
subtleGradient d1fd405
sauce labs browser configs for running manually
subtleGradient c4cd02e
fixes #513
subtleGradient 22829b5
remove unnecessary task config
subtleGradient File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ docs/js/examples | |
| docs/downloads | ||
| examples/shared/*.js | ||
| test/the-files-to-test.generated.js | ||
| sauce_connect.log* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,42 +1,38 @@ | ||
| var pxlgif = Buffer('R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64'); | ||
|
|
||
| module.exports = function(grunt){ | ||
|
|
||
| function printMiddleware(req, res, next) { | ||
| if (req._parsedUrl.pathname != '/print') return next(); | ||
| if (req.query.message.indexOf('ok') === 0){ | ||
| grunt.log.ok(req.query.message); | ||
| } else if (req.query.message.indexOf('not ok') === 0){ | ||
| grunt.log.error(req.query.message); | ||
| } else { | ||
| grunt[req.query.type || 'log'].writeln('[%s][%s]', req.headers['user-agent'], Date.now(), req.query.message); | ||
| } | ||
| res.end(pxlgif); | ||
| } | ||
|
|
||
| function testResultLoggerMiddleware(req, res, next) { | ||
| if (!(req.body && req.body.data)) return next(); | ||
| grunt.log.writeln('[%s][%s]', req.headers['user-agent'], Date.now(), req.body.data); | ||
| if (!(req.method == 'POST' && req._parsedUrl.pathname.indexOf('/reportTestResults') === 0)) return next(); | ||
| var logType = 'writeln'; | ||
| var message = req.body; | ||
|
|
||
| if (req.body.type && req.body.message){ | ||
| if (req.body.type == 'error') logType = 'error'; | ||
| else if (req.body.message.indexOf('ok') === 0) logType = 'ok'; | ||
| else if (req.body.message.indexOf('not ok') === 0) logType = 'error'; | ||
| message = req.body.message; | ||
| } | ||
| if (typeof message != 'string') message = JSON.stringify(message, null, 2); | ||
| grunt.log[logType]('[%s][%s]', req.headers['user-agent'], Date.now(), message); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did we figure out if
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| res.write('<!doctype html><meta charset=utf-8>'); | ||
| res.end('Got it, thanks!'); | ||
| } | ||
|
|
||
| return { | ||
| server: { | ||
| options: { | ||
| base: '.', | ||
| hostname: '*', | ||
| port: 9999, | ||
| middleware: function(connect, options) { | ||
|
|
||
| connect.logger.token('user-agent', function(req, res){ return req.headers['user-agent']; }); | ||
| connect.logger.token('timestamp', function(req, res){ return Date.now(); }); | ||
|
|
||
| return [ | ||
| connect.query(), | ||
| printMiddleware, | ||
|
|
||
| connect.logger({format:'[:user-agent][:timestamp] :method :url', stream:grunt.verbose}), | ||
| connect.bodyParser(), | ||
| connect.json(), | ||
| testResultLoggerMiddleware, | ||
|
|
||
| connect.logger({format:'[:user-agent][:timestamp] :method :url', stream:grunt.verbose}), | ||
| connect.static(options.base), | ||
| connect.directory(options.base) | ||
| ]; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| var grunt = require('grunt'); | ||
| var SauceTunnel = require('sauce-tunnel'); | ||
|
|
||
| module.exports = function(){ | ||
| var task = this; | ||
| var config = task.data; | ||
| var shouldStayAliveForever = task.flags.keepalive; | ||
|
|
||
| var SAUCE_ACCESS_KEY = process.env.SAUCE_ACCESS_KEY; | ||
| if (!SAUCE_ACCESS_KEY) grunt.fatal('Requires the environment variable SAUCE_ACCESS_KEY to be set'); | ||
|
|
||
| var SAUCE_USERNAME = process.env.SAUCE_USERNAME; | ||
| if (!SAUCE_USERNAME) grunt.fatal('Requires the environment variable SAUCE_USERNAME to be set'); | ||
|
|
||
| var IDENTIFIER = process.env.TRAVIS_JOB_NUMBER || 'my awesome tunnel'; | ||
|
|
||
| var taskCompletedSuccessfully = task.async(); | ||
|
|
||
| var stunnel = new SauceTunnel(SAUCE_USERNAME, SAUCE_ACCESS_KEY, IDENTIFIER, /*tunneled*/true, /*tunnelTimeout*/5); | ||
| process.on('exit', stunnel.stop.bind(stunnel, function(){})); | ||
|
|
||
| stunnel.on('log:error', grunt.log.error.bind(grunt.log)); | ||
| stunnel.on('log:writeln', grunt.log.writeln.bind(grunt.log)); | ||
|
|
||
| stunnel.on('verbose:ok', grunt.verbose.ok.bind(grunt.verbose)); | ||
| stunnel.on('verbose:error', grunt.verbose.error.bind(grunt.verbose)); | ||
| stunnel.on('verbose:debug', grunt.verbose.debug.bind(grunt.verbose)); | ||
| stunnel.on('verbose:writeln', grunt.verbose.writeln.bind(grunt.verbose)); | ||
|
|
||
| stunnel.openTunnel(function(isOpen){ | ||
| if (shouldStayAliveForever && isOpen){ | ||
| grunt.verbose.writeln('Keeping the sauce-tunnel open forever because you used the keepalive flag `' + task.nameArgs + '`'); | ||
| return; | ||
| } | ||
| grunt.verbose.writeln('To keep the sauce-tunnel open forever, use the grunt task `' + task.nameArgs + ':keepalive`'); | ||
| taskCompletedSuccessfully(isOpen); | ||
| }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also remove the obsolete parts from
grunt/config/jsx/jsx.js?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.