Permalink
Browse files

added phantomjs test runner for travis CI.

  • Loading branch information...
1 parent 2af9493 commit 9f67345e65c9aa152abbb00f8e838b321d1eb837 @toolness toolness committed Oct 19, 2012
Showing with 75 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 .travis.yml
  3. +12 −0 package.json
  4. +13 −0 test/index.html
  5. +25 −0 test/phantom/phantom.js
  6. +21 −0 test/phantom/run.js
View
@@ -1 +1,2 @@
.DS_Store
+node_modules
View
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.8
View
@@ -0,0 +1,12 @@
+{ "name": "webmaker-nav"
+, "description": "Universal navigation for Mozilla Webmaker properties."
+, "version": "0.1.0"
+, "private": true
+, "scripts" :
+ { "test" : "node test/phantom/run.js" }
+, "dependencies":
+ { "express": "2.5.x"
+ }
+, "engines":
+ { "node": "*" }
+}
View
@@ -23,6 +23,19 @@ <h2 id="qunit-userAgent"></h2>
QUnit.config.testTimeout = 5000;
defineTests.run(["test/all-tests"]);
+ if (window.inPhantomJS) {
+ QUnit.testStart(function(details) {
+ console.log(details.module + " : " + details.name);
+ });
+ QUnit.testDone(function(details) {
+ console.log(" " + details.passed + " of " + details.total +
+ " assertions passed.");
+ });
+ QUnit.done(function(details) {
+ console.log("END:" + JSON.stringify(details));
+ });
+ }
+
if (location.search.match(/externalreporter=1/))
document.write('<script src="/externalreporter.js"></' + 'script>');
</script>
View
@@ -0,0 +1,25 @@
+var page = new WebPage();
+page.onConsoleMessage = function(msg) {
+ console.log(msg);
+ if (msg.indexOf('END:') == 0) {
+ var results = JSON.parse(msg.slice(4));
+ var passed = results.total - results.failed;
+ console.log(passed + " of " + results.total + " browser tests passed.");
+ phantom.exit(results.failed);
+ }
+};
+
+page.onInitialized = function() {
+ page.evaluate(function() {
+ window.inPhantomJS = true;
+ });
+};
+
+var url = 'http://127.0.0.1:8051/test/';
+
+console.log('opening ' + url);
+
+page.open(url, function(status) {
+ if (status != "success")
+ return phantom.exit(1);
+});
View
@@ -0,0 +1,21 @@
+var express = require('express'),
+ path = require('path'),
+ spawn = require('child_process').spawn,
+ app = express.createServer(),
+ port = 8051,
+ dirname = path.normalize(__dirname + '/../..');
+
+app.use(express.static(dirname));
+
+app.listen(port, function() {
+ console.log("serving on port " + port + " files in " + dirname);
+ var phantom = spawn('phantomjs', [__dirname + '/phantom.js']);
+ phantom.stdout.setEncoding('utf8');
+ phantom.stderr.setEncoding('utf8');
+ phantom.stdout.on('data', function(chunk) { console.log(chunk); });
+ phantom.stderr.on('data', function(chunk) { console.log(chunk); });
+ phantom.on('exit', function(status) {
+ console.log('phantomjs exited with code', status);
+ process.exit(status);
+ });
+});

0 comments on commit 9f67345

Please sign in to comment.