Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added phantomjs test runner for travis CI.

  • Loading branch information...
commit 9f67345e65c9aa152abbb00f8e838b321d1eb837 1 parent 2af9493
@toolness toolness authored
View
1  .gitignore
@@ -1 +1,2 @@
.DS_Store
+node_modules
View
3  .travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+ - 0.8
View
12 package.json
@@ -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
13 test/index.html
@@ -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
25 test/phantom/phantom.js
@@ -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
21 test/phantom/run.js
@@ -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);
+ });
+});
Please sign in to comment.
Something went wrong with that request. Please try again.