Skip to content
Browse files

unit test runner support

  • Loading branch information...
1 parent 8fa9b0e commit 43fc752ec5c8e510a48e2ef44761ec2baf97117f @netguy204 committed Jul 6, 2012
Showing with 39 additions and 0 deletions.
  1. +39 −0 phantom/unit-test.js
View
39 phantom/unit-test.js
@@ -0,0 +1,39 @@
+if (phantom.args.length != 1) {
+ console.log('Expected a target URL parameter.');
+ phantom.exit(1);
+}
+
+var page = require('webpage').create();
+var url = phantom.args[0];
+
+page.onConsoleMessage = function (message) {
+ console.log("Test console: " + message);
+};
+
+console.log("Loading URL: " + url);
+
+page.open(url, function (status) {
+ if (status != "success") {
+ console.log('Failed to open ' + url);
+ phantom.exit(1);
+ }
+
+ console.log("Running test.");
+
+ var result = page.evaluate(function() {
+ return move.test.run();
+ });
+
+ // NOTE: PhantomJS 1.4.0 has a bug that prevents the exit codes
+ // below from being returned properly. :(
+ //
+ // http://code.google.com/p/phantomjs/issues/detail?id=294
+
+ if (result != 0) {
+ console.log("*** Test failed! ***");
+ phantom.exit(1);
+ }
+
+ console.log("Test succeeded.");
+ phantom.exit(0);
+});

0 comments on commit 43fc752

Please sign in to comment.
Something went wrong with that request. Please try again.